After canceling end edit mode in a xamdatagrid the cell that is in edit mode stays in edit mode, but loses focus and the user must click the cell again.
Is this the default behavior?
Is it possible for the cell to maintain focus and have the text in the cell selected?
I have a similar issue when cancelling edit mode. Below is a sample code:
private void XamDataGrid_EditModeEnding(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndingEventArgs e)
{
if(hasError)
MessageBox.Show("An error occured...", "Error occured", MessageBoxButton.OK, MessageBoxImage.Error);
e.Cancel = true;
grid.ActiveCell = e.Cell;
grid.ExecuteCommand(DataPresenterCommands.StartEditMode);
}
When cell loses focus by selecting another row with the above code, the cell regains focus and enters edit mode. However if i select another control in which the grid loses focus the above code doesnt' work properly, the cell doesn't regain focus. How should i fix this?
Hello,
I can suggest you sue the follwoing code instead of yours:
if (hasError) { MessageBox.Show("An error occured...", "Error occured", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; Dispatcher.BeginInvoke(new Action(() => { if (!(FocusManager.GetFocusedElement(this) is SectionsList)) { xamDataGrid1.Focus(); } xamDataGrid1.ActiveCell = e.Cell; xamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode); }), DispatcherPriority.Background, null); }
this way yo ucandetermine whether the XamDataGrid loses focus or not and make it focused again.
Hope this helps you.