使用Silverlight / WPF Datagrid并在现有集合中添加新行时,如何跳转到特定单元格的编辑模式,以便提示用户需要立即填写此字段?
非常感谢,
答案 0 :(得分:6)
这就是我能够在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
希望这有帮助。
答案 1 :(得分:0)
在Silverlight 4中它是:
dg.SelectedItem = data;
dg.CurrentColumn = dg.Columns[1]; // You have to use this line instead
dg.Focus();
dg.BeginEdit();