1

私はこの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 または si を押すと、選択した項目が KeyPressed にバインドされます。私の問題は、どのキーを押したかをどのように知ることができるかです。(押されたキーと選択されたアイテムをバインドしたい)

4

1 に答える 1

2

2 つのキーバインドがある場合は、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>
于 2012-09-03T12:48:30.810 に答える