tabControl.SelectionChanged += tabControl_SelectionChanged; void tabControl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { var removedItems = e.RemovedItems; foreach(var removedItem in removedItems) { var expander = (removedItem as TabItem).Content as Expander; var grid = expander.Content as SfDataGrid; if (grid != null && grid.SelectionController.CurrentCellManager.CurrentCell != null && grid.SelectionController.CurrentCellManager.CurrentCell.IsEditing) grid.SelectionController.CurrentCellManager.EndEdit(); } |
// KeyBoard Lost Focus Event
this.datagrid.LostKeyboardFocus += DataGrid_LostKeyboardFocus;
void dataGrid1_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
if (!this.dataGrid1.IsKeyboardFocusWithin)
{
this.dataGrid1.SelectionController.CurrentCellManager.EndEdit();
}
} |