Skip to content

Commit

Permalink
Fixes AlternatingRowForeground not being applied when in Light theme
Browse files Browse the repository at this point in the history
  • Loading branch information
thiago-cs committed Aug 4, 2021
1 parent e8540d8 commit 13f40bb
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/DataGridRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 13f40bb

Please sign in to comment.