Hello,
When an XamDataGrid cell in edit mode, may I press the Up or Down key to move the edit mode to the adjacent cell? If so, are there any examples?
Thanks.
Here is one way to achieve this by handling the PreviewKeyDown event of the XamDataGrid :
void xamDataGrid1_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (!xamDataGrid1.ActiveCell.IsInEditMode)
return;
}
if (e.Key == Key.Left)
xamDataGrid1.ExecuteCommand(DataPresenterCommands.EndEditModeAndAcceptChanges);
xamDataGrid1.ExecuteCommand(DataPresenterCommands.CellLeft);
xamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);
if (e.Key == Key.Right)
xamDataGrid1.ExecuteCommand(DataPresenterCommands.CellRight);
if (e.Key == Key.Up)
xamDataGrid1.ExecuteCommand(DataPresenterCommands.CellAbove);
if (e.Key == Key.Down)
xamDataGrid1.ExecuteCommand(DataPresenterCommands.CellBelow);
I'm using XamDataGrid Version 12.2 and tryin' to achieve the same as above but your solution doesn't seem to work for me. There are two problems:
1) I have three Columns A, B, C with Fieldsettings.AllowEdit of B set to false. If I use right arrow to move from cell A to B, B is automatically skipped and focus is on cell C but it's not in edit mode because PreviewKeyDown-Event wasn't fired.
2) Cell value isn't selected in edit mode
It works great. Thank you very much.