私は、InputBindings (Enter キーと Delete キー) を持つ別のグリッドを含むグリッドを含むウィンドウと、他のコントロールの中でも読み取り専用の DataGrid を持っています。
DataGrid にフォーカスがある場合、InputBindings はコマンドの実行を停止します。その後、InputBindings が機能する前に、別のコントロールに手動でフォーカスを移す必要があります。
この動作を回避するにはどうすればよいですか? ほとんどすべての入力/キーボード関連の DataGrid のプロパティで試してみましたが、成功しませんでした。
テーブルにはあまり関係ありませんが、XAML は次のとおりです。
<Grid>
<Grid.InputBindings>
<KeyBinding Key="Enter" Command="{Binding DoStuff}"/>
<KeyBinding Key="Delete" Command="{Binding UndoStuff}"/>
</Grid.InputBindings>
<!-- stuff... -->
<Grid >
<!-- more stuff... -->
<DataGrid IsReadOnly="True" ItemsSource="{Binding SomeProperty}" SelectedItem="{Binding SomeSelectedProperty, Mode=TwoWay}">
<DataGrid.Columns>
<!-- blah -->
</DataGrid.Columns>
</DataGrid>
</Grid>
</Grid>