我正在使用WPF DataGrid。默认情况下,DataGrid键盘进入ComboBox时(在Datagrid中)卡住了快捷方式。
我尝试过PreviewKeyDown,当我按箭头按钮时,它不在DatagridCells中导航,而是从顶部/第一个UI元素来的。
private void dataGrid1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Up)
{
MoveFocus(new TraversalRequest(FocusNavigationDirection.Up));
MessageBox.Show(sender.ToString());
}
else if (e.Key == Key.Down)
{
MoveFocus(new TraversalRequest(FocusNavigationDirection.Down));
}
else if(e.Key == Key.Right)
{
MoveFocus(new TraversalRequest(FocusNavigationDirection.Right));
}
else if(e.Key == Key.Left)
{
MoveFocus(new TraversalRequest(FocusNavigationDirection.Left));
}
}
我要更改此设置,以使“向右/向左”将在整个行中导航,而“向上/向下”将在整个Datagrid垂直地导航。