Skip to content

Commit 13f40bb

Browse files
committed
Fixes AlternatingRowForeground not being applied when in Light theme
1 parent e8540d8 commit 13f40bb

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

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

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,40 +1122,11 @@ internal void EnsureForeground()
11221122
{
11231123
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
11241124

1125-
PropertyMetadata metadataInfo = DataGridRow.ForegroundProperty.GetMetadata(typeof(DataGridRow));
1126-
Brush defaultForeground = metadataInfo == null ? null : metadataInfo.DefaultValue as Brush;
1127-
Brush newForeground = null;
1125+
var newForeground = this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null
1126+
? this.OwningGrid.RowForeground
1127+
: this.OwningGrid.AlternatingRowForeground;
11281128

1129-
if (this.Foreground.Equals(defaultForeground))
1130-
{
1131-
if (this.Index % 2 == 0 || this.OwningGrid.AlternatingRowForeground == null)
1132-
{
1133-
// Use OwningGrid.RowForeground if the index is even or if the OwningGrid.AlternatingRowForeground is null
1134-
if (this.OwningGrid.RowForeground != null)
1135-
{
1136-
newForeground = this.OwningGrid.RowForeground;
1137-
}
1138-
}
1139-
else
1140-
{
1141-
// Alternate row
1142-
if (this.OwningGrid.AlternatingRowForeground != null)
1143-
{
1144-
newForeground = this.OwningGrid.AlternatingRowForeground;
1145-
}
1146-
}
1147-
1148-
if (newForeground == null)
1149-
{
1150-
newForeground = this.Foreground;
1151-
}
1152-
}
1153-
else
1154-
{
1155-
newForeground = this.Foreground;
1156-
}
1157-
1158-
this.ComputedForeground = newForeground;
1129+
this.ComputedForeground = newForeground ?? this.Foreground;
11591130
}
11601131
else
11611132
{

0 commit comments

Comments
 (0)