[英]Select the wpf datagrid cell at runtime
My scenario: Data loads in to my data grid page by page On key down of the last row on w pf data grid, i will load another row in the end. 我的场景:数据逐页加载到我的数据网格中在w pf数据网格的最后一行的关键按下时,我将最后加载另一行。 this way after binding with the new rows after key down focus on the last selected cell is lost.
这样,在按下键后失去对最后一个选定单元格的关注之后,便与新行绑定。 i want to retain the selection on the last+1 (row and column) cell.
我想保留最后+1(行和列)单元格上的选择。 How can i set this.
我该如何设置。
There is event SourceUpdated
, so you could do something like that: 有事件
SourceUpdated
,因此您可以执行以下操作:
private void DataGrid_SourceUpdated(object sender, DataTransferEventArgs e)
{
(sender as DataGrid).SelectedIndex = (sender as DataGrid).Items.Count - 1;
}
It could help also: How to select a row or a cell in WPF DataGrid programmatically? 它也可能会有所帮助: 如何以编程方式在WPF DataGrid中选择行或单元格?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.