From 1a67e944cfb25b23c0e2ebf6c1dc9c1dbc104c16 Mon Sep 17 00:00:00 2001
From: Thiago Siqueira <71464913+thiago-cs@users.noreply.github.com>
Date: Wed, 28 Jul 2021 14:12:15 -0300
Subject: [PATCH 1/4] Fixes DataGrid colors not updating on theme switch
---
.../DataGrid/DataGrid.xaml | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml
index b16f8583450..b6365ae5477 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGrid.xaml
@@ -28,6 +28,10 @@
+
+
+
+
@@ -41,6 +45,10 @@
+
+
+
+
@@ -54,6 +62,10 @@
+
+
+
+
@@ -89,13 +101,9 @@
-
-
-
-
@@ -967,4 +975,4 @@
-
\ No newline at end of file
+
From 53bc957312d85fec4c9f34c15375c9ad3c8db7e7 Mon Sep 17 00:00:00 2001
From: Thiago Siqueira <71464913+thiago-cs@users.noreply.github.com>
Date: Wed, 28 Jul 2021 14:38:35 -0300
Subject: [PATCH 2/4] Fixes AlternatingRowForeground not being applied
Fixes AlternatingRowForeground not being applied when in Light theme.
---
.../DataGrid/DataGridRow.cs | 39 +++----------------
1 file changed, 5 insertions(+), 34 deletions(-)
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
index 86840408c42..c2619771418 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
@@ -1122,40 +1122,11 @@ internal void EnsureForeground()
{
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
- PropertyMetadata metadataInfo = DataGridRow.ForegroundProperty.GetMetadata(typeof(DataGridRow));
- Brush defaultForeground = metadataInfo == null ? null : metadataInfo.DefaultValue as Brush;
- Brush newForeground = null;
+ var newForeground = this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null
+ ? this.OwningGrid.RowForeground
+ : this.OwningGrid.AlternatingRowForeground;
- if (this.Foreground.Equals(defaultForeground))
- {
- if (this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null)
- {
- // Use OwningGrid.RowForeground if the index is even or if the OwningGrid.AlternatingRowForeground is null
- if (this.OwningGrid.RowForeground != null)
- {
- newForeground = this.OwningGrid.RowForeground;
- }
- }
- else
- {
- // Alternate row
- if (this.OwningGrid.AlternatingRowForeground != null)
- {
- newForeground = this.OwningGrid.AlternatingRowForeground;
- }
- }
-
- if (newForeground == null)
- {
- newForeground = this.Foreground;
- }
- }
- else
- {
- newForeground = this.Foreground;
- }
-
- this.ComputedForeground = newForeground;
+ this.ComputedForeground = newForeground ?? this.Foreground;
}
else
{
@@ -1531,4 +1502,4 @@ public int Debug_Index
}
#endif
}
-}
\ No newline at end of file
+}
From 3e64e6790d17a29e9e7a29d2e1925230fdccc5e1 Mon Sep 17 00:00:00 2001
From: Thiago Siqueira <71464913+thiago-cs@users.noreply.github.com>
Date: Thu, 29 Jul 2021 01:27:39 -0300
Subject: [PATCH 3/4] Revert "Fixes AlternatingRowForeground not being applied"
This reverts commit 53bc957312d85fec4c9f34c15375c9ad3c8db7e7.
---
.../DataGrid/DataGridRow.cs | 39 ++++++++++++++++---
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
index c2619771418..86840408c42 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
@@ -1122,11 +1122,40 @@ internal void EnsureForeground()
{
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
- var newForeground = this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null
- ? this.OwningGrid.RowForeground
- : this.OwningGrid.AlternatingRowForeground;
+ PropertyMetadata metadataInfo = DataGridRow.ForegroundProperty.GetMetadata(typeof(DataGridRow));
+ Brush defaultForeground = metadataInfo == null ? null : metadataInfo.DefaultValue as Brush;
+ Brush newForeground = null;
- this.ComputedForeground = newForeground ?? this.Foreground;
+ if (this.Foreground.Equals(defaultForeground))
+ {
+ if (this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null)
+ {
+ // Use OwningGrid.RowForeground if the index is even or if the OwningGrid.AlternatingRowForeground is null
+ if (this.OwningGrid.RowForeground != null)
+ {
+ newForeground = this.OwningGrid.RowForeground;
+ }
+ }
+ else
+ {
+ // Alternate row
+ if (this.OwningGrid.AlternatingRowForeground != null)
+ {
+ newForeground = this.OwningGrid.AlternatingRowForeground;
+ }
+ }
+
+ if (newForeground == null)
+ {
+ newForeground = this.Foreground;
+ }
+ }
+ else
+ {
+ newForeground = this.Foreground;
+ }
+
+ this.ComputedForeground = newForeground;
}
else
{
@@ -1502,4 +1531,4 @@ public int Debug_Index
}
#endif
}
-}
+}
\ No newline at end of file
From 13f40bb9fc81e66ae238f2cefc885c7cf77424c5 Mon Sep 17 00:00:00 2001
From: Thiago Siqueira <71464913+thiago-cs@users.noreply.github.com>
Date: Wed, 4 Aug 2021 18:07:26 -0300
Subject: [PATCH 4/4] Fixes AlternatingRowForeground not being applied when in
Light theme
---
.../DataGrid/DataGridRow.cs | 37 ++-----------------
1 file changed, 4 insertions(+), 33 deletions(-)
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
index 86840408c42..c721cf7efad 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
@@ -1122,40 +1122,11 @@ internal void EnsureForeground()
{
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
- PropertyMetadata metadataInfo = DataGridRow.ForegroundProperty.GetMetadata(typeof(DataGridRow));
- Brush defaultForeground = metadataInfo == null ? null : metadataInfo.DefaultValue as Brush;
- Brush newForeground = null;
+ var newForeground = this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null
+ ? this.OwningGrid.RowForeground
+ : this.OwningGrid.AlternatingRowForeground;
- if (this.Foreground.Equals(defaultForeground))
- {
- if (this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null)
- {
- // Use OwningGrid.RowForeground if the index is even or if the OwningGrid.AlternatingRowForeground is null
- if (this.OwningGrid.RowForeground != null)
- {
- newForeground = this.OwningGrid.RowForeground;
- }
- }
- else
- {
- // Alternate row
- if (this.OwningGrid.AlternatingRowForeground != null)
- {
- newForeground = this.OwningGrid.AlternatingRowForeground;
- }
- }
-
- if (newForeground == null)
- {
- newForeground = this.Foreground;
- }
- }
- else
- {
- newForeground = this.Foreground;
- }
-
- this.ComputedForeground = newForeground;
+ this.ComputedForeground = newForeground ?? this.Foreground;
}
else
{