在我的 WPF 应用程序中,我有一个自定义键绑定(bind)到我的命令之一:
<KeyBinding Modifiers="Control" Key="A" Command="local:MainWindow.SelectAll" />
(它的作用是选择带有边界框的图像上的整个区域供以后处理。)
主窗口中还有一个DataGrid。 Ctrl+A
键在应用程序上运行良好,直到我单击 DataGrid。从那时起,DataGrid 将处理它(但不执行任何操作,因为它不是多选网格)。
我怎样才能实现 DataGrid 不处理 Ctrl+A
,所以它总是会触发我的命令?
如果有帮助,这是我的 DataGrid:
<DataGrid Name="myDataGrid" ItemsSource="{Binding}" SelectionMode="Single"
EnableRowVirtualization="True" SelectedCellsChanged="myDataGrid_SelectedCellsChanged"
IsReadOnly="True" />
最佳答案
您可以使用以下方法删除此类包含的绑定(bind):
<DataGrid>
<DataGrid.InputBindings>
<KeyBinding Gesture="Ctrl+A" Command="ApplicationCommands.NotACommand"/>
</DataGrid.InputBindings>
</DataGrid>
关于c# - WPF - DataGrid 不应处理 Ctrl+A,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16855921/