Reputation: 66380
When using Silverlight/WPF Datagrid and you add a new row to the existing collection, how can I jump into a specific cell's edit mode in order to hint to the user that this field needs to be filled out right away?
Many Thanks,
Upvotes: 2
Views: 5045
Reputation: 413
In Silverlight 4 it is:
dg.SelectedItem = data;
dg.CurrentColumn = dg.Columns[1]; // You have to use this line instead
dg.Focus();
dg.BeginEdit();
Upvotes: 0
Reputation: 667
This is how I was able to make it work in 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
Hope this helps.
Upvotes: 7