Skip to content

Commit cc2a51e

Browse files
lukeblevinsmichael-hawker
authored andcommitted
fix: Prevent focus reset for DataGridTemplateColumn
1 parent 0ee2c84 commit cc2a51e

File tree

1 file changed

+12
-1
lines changed
  • Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid

1 file changed

+12
-1
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5729,6 +5729,7 @@ private void DataGrid_LostFocus(object sender, RoutedEventArgs e)
57295729
{
57305730
bool focusLeftDataGrid = true;
57315731
bool dataGridWillReceiveRoutedEvent = true;
5732+
DataGridColumn editingColumn = null;
57325733

57335734
// Walk up the visual tree of the newly focused element
57345735
// to determine if focus is still within DataGrid.
@@ -5768,7 +5769,17 @@ private void DataGrid_LostFocus(object sender, RoutedEventArgs e)
57685769
focusedDependencyObject = parent;
57695770
}
57705771

5771-
if (focusLeftDataGrid)
5772+
if (this.EditingRow != null && this.EditingColumnIndex != -1)
5773+
{
5774+
editingColumn = this.ColumnsItemsInternal[this.EditingColumnIndex];
5775+
5776+
if (focusLeftDataGrid && editingColumn is DataGridTemplateColumn)
5777+
{
5778+
dataGridWillReceiveRoutedEvent = false;
5779+
}
5780+
}
5781+
5782+
if (focusLeftDataGrid && !(editingColumn is DataGridTemplateColumn))
57725783
{
57735784
this.ContainsFocus = false;
57745785
if (this.EditingRow != null)

0 commit comments

Comments
 (0)