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().
I found an anwer, set the cell Active first (even though it already is :-)
_dataPresenter.BringCellIntoView(_dataPresenter.ActiveCell);
and then StartEditMode
_dataPresenter.ExecuteCommand(DataPresenterCommands.StartEditMode);
I have the same request so bumping this question, the problem is Focus
I have a toolbar that AllowsEdit and then tries to StartEditMode but it does not work as the Grid does not have focus. the code below works and without the below above commands it does not work. (I do not suggest using this but it shows once with focus StartEditMode works)
_dataPresenter.ExecuteCommand(DataPresenterCommands.CellBelow);_dataPresenter.ExecuteCommand(DataPresenterCommands.CellAbove);_dataPresenter.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; }}
You first need to set the ActiveCell then execute the StartEditMode command, e.g.
this.XamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);