WPF DataGrid add a new row if we press tab on last column of last row. But after adding the new row, the focus is moved to top row of the grid. How can we make sure that the focus is moved to the first column of new row?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You could try something like
this.SelectRowCell(this.Items.Count - 1, 0);
But I'm not sure if that will set the focus too. If not then try the following:
DataGridCell cell = this.GetCell(this.Items.Count - 1, 0);
if (cell != null)
{
cell.Focus();
}