diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs index fcff002c18c..85a7a32aba2 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.cs @@ -448,9 +448,21 @@ public DataGrid() this.DefaultStyleKey = typeof(DataGrid); + ActualThemeChanged += this.DataGrid_ActualThemeChanged; + HookDataGridEvents(); } + private void DataGrid_ActualThemeChanged(FrameworkElement sender, object args) + { + DataGrid dataGrid = sender as DataGrid; + foreach (DataGridRow row in dataGrid.GetAllRows()) + { + row.EnsureBackground(); + row.EnsureForeground(); + } + } + /// /// Gets or sets the that is used to paint the background of odd-numbered rows. /// @@ -5890,6 +5902,8 @@ private void DataGrid_Unloaded(object sender, RoutedEventArgs e) { _showingMouseIndicators = false; _keepScrollBarsShowing = false; + + ActualThemeChanged -= this.DataGrid_ActualThemeChanged; } #if FEATURE_VALIDATION diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml index b6365ae5477..af3fcdcf050 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml @@ -32,6 +32,7 @@ + @@ -49,6 +50,7 @@ + @@ -66,6 +68,7 @@ + @@ -91,7 +94,6 @@ -