diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs index 561e69e4182..35814fff6fb 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs @@ -5729,6 +5729,7 @@ private void DataGrid_LostFocus(object sender, RoutedEventArgs e) { bool focusLeftDataGrid = true; bool dataGridWillReceiveRoutedEvent = true; + DataGridColumn editingColumn = null; // Walk up the visual tree of the newly focused element // to determine if focus is still within DataGrid. @@ -5768,7 +5769,17 @@ private void DataGrid_LostFocus(object sender, RoutedEventArgs e) focusedDependencyObject = parent; } - if (focusLeftDataGrid) + if (this.EditingRow != null && this.EditingColumnIndex != -1) + { + editingColumn = this.ColumnsItemsInternal[this.EditingColumnIndex]; + + if (focusLeftDataGrid && editingColumn is DataGridTemplateColumn) + { + dataGridWillReceiveRoutedEvent = false; + } + } + + if (focusLeftDataGrid && !(editingColumn is DataGridTemplateColumn)) { this.ContainsFocus = false; if (this.EditingRow != null)