当使用 Silverlight/WPF Datagrid 并向现有集合添加新行时,我如何才能跳转到特定单元格的编辑模式以提示用户需要立即填写此字段?
非常感谢,
最佳答案
这就是我如何让它在 SL 5 RC 中工作的。
dg.ItemsSource.Add(data);
dg.SelectedItem = data; //set SelectedItem to the new object
dg.ScrollIntoView(data, dg.Columns[0]); //scroll row into view, for long lists, setting it to start with the first column
dg.Focus(); //required in my case because contextmenu click was not setting focus back to datagrid
dg.BeginEdit(); //this starts the edit, this works because we set SelectedItem above
希望这对您有所帮助。
关于c# - 向 Datagrid 添加新行时如何关注特定单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6720137/