I want to programmatically set specific cell into edit mode.
How to do that?
I see only cell.EndEditMode() method. I need smth. like cell.StartEditMode().
You first need to set the ActiveCell then execute the StartEditMode command, e.g.
this.XamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);
I am trying to initiate an inplace edit via a command handler. I have serveral grids and edit buttons, and the grid is located via an argument passed into the command via the command parameter.
I can manually initiate editing.
I know the correct grid is being identified.
I know that there is an active cell.
I can't get it to switch into edit mode, though.
NOTE: If I first double-click a cell to go into edit mode and then hit ESCAPE, the cell shows a dashed outline. If I then execute my Command, the cell switches back into edit mode. Very strange.
=======
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e){ RoutedCommand cmd = e.Command as RoutedCommand;
switch (cmd.Name.ToLower()) {
case "edit": { XamDataGrid grid = FindCommandTargetGrid(e.Parameter);
if (grid != null) { grid.ExecuteCommand(DataPresenterCommands.StartEditMode); } } break; }}