gpt4 book ai didi

wpf - DataGrid Multiple KeyBinding到相同的功能,如何知道我按下了哪个键

转载 作者:行者123 更新时间:2023-12-03 10:29:33 25 4
gpt4 key购买 nike

我有这个 xaml:

<DataGrid.InputBindings>
<KeyBinding Key="a" Command="{Binding Path=Function}" CommandParameter="{Binding ElementName=dataGrid1,Path=SelectedItem}"></KeyBinding>
<KeyBinding Key="s" Command="{Binding Path=Function}" CommandParameter="{Binding ElementName=dataGrid1,Path=SelectedItem}"></KeyBinding>
</DataGrid.InputBindings>

当我选择一行并按 a 或 s 时,我将所选项目绑定(bind)到 KeyPressed。我的问题是我怎么知道我按下了哪个键? (我想绑定(bind)按键和选定的项目)

最佳答案

如果您有 2 个键绑定(bind),则有 2 个不同的命令会更清楚:

<DataGrid.InputBindings>
<KeyBinding Key="a" Command="{Binding Path=ACommand}" CommandParameter="{Binding ElementName=dataGrid1,Path=SelectedItem}"></KeyBinding>
<KeyBinding Key="s" Command="{Binding Path=SCommand}" CommandParameter="{Binding ElementName=dataGrid1,Path=SelectedItem}"></KeyBinding>
</DataGrid.InputBindings>

关于wpf - DataGrid Multiple KeyBinding到相同的功能,如何知道我按下了哪个键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12245009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com