In my WPF application I have a custom key binding to one of my commands:
<KeyBinding Modifiers="Control" Key="A" Command="local:MainWindow.SelectAll" />
(What it does is it select the whole area on an image with a bounding box for later processing.)
There is also a DataGrid in the main window. The Ctrl+A
key works well on the application until I once clicked into the DataGrid. From that point, the DataGrid handles it (but doesn't do anything since it is not a multiselect grid).
How can I achieve the the DataGrid doesn't handle Ctrl+A
, so it will always fire my command?
Here's my DataGrid if that helps:
<DataGrid Name="myDataGrid" ItemsSource="{Binding}" SelectionMode="Single"
EnableRowVirtualization="True" SelectedCellsChanged="myDataGrid_SelectedCellsChanged"
IsReadOnly="True" />
You can remove this kind of included binding by using this:
<DataGrid>
<DataGrid.InputBindings>
<KeyBinding Gesture="Ctrl+A" Command="ApplicationCommands.NotACommand"/>
</DataGrid.InputBindings>
</DataGrid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With