【发布时间】:2023-03-22 03:29:02
【问题描述】:
当使用 Silverlight/WPF Datagrid 并向现有集合添加新行时,如何跳转到特定单元格的编辑模式以提示用户该字段需要立即填写?
非常感谢,
【问题讨论】:
标签: c# .net wpf silverlight datagrid
当使用 Silverlight/WPF Datagrid 并向现有集合添加新行时,如何跳转到特定单元格的编辑模式以提示用户该字段需要立即填写?
非常感谢,
【问题讨论】:
标签: c# .net wpf silverlight datagrid
在 Silverlight 4 中是:
dg.SelectedItem = data;
dg.CurrentColumn = dg.Columns[1]; // You have to use this line instead
dg.Focus();
dg.BeginEdit();
【讨论】:
这就是我如何让它在 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
希望这会有所帮助。
【讨论】: