WPF DataGrid - 如何在按Tab键后将键盘焦点移动到新添加的行

Gop*_*ath 6 wpftoolkit wpfdatagrid

如果我们在最后一行的最后一列上按Tab键,WPF DataGrid会添加一个新行.但是在添加新行之后,焦点将移动到网格的顶行.我们如何确保焦点移动到新行的第一列?

Sam*_*Sam -1

你可以尝试类似的东西

this.SelectRowCell(this.Items.Count - 1, 0);
Run Code Online (Sandbox Code Playgroud)

但我不确定这是否也会成为焦点。如果没有,请尝试以下操作:

DataGridCell cell = this.GetCell(this.Items.Count - 1, 0);

if (cell != null)
{
    cell.Focus();
}
Run Code Online (Sandbox Code Playgroud)