Skip to content

Fixed DataGrid column header text color in HC mode #10956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dipeshmsft
Copy link
Member

@dipeshmsft dipeshmsft commented Jun 27, 2025

Description

In HC mode, the DataGrid column header text color was not visible. DataGrid column header was inheriting foreground color from the DataGrid control. This PR introduces a new resource DataGridColumnHeaderForeground color which is now used as the color of the column header text.

Customer Impact

Customers using Desert mode won't be able to see the column headers correctly.

Regression

Yes. Introduced in .NET 10 Preview 5 / 6.

Testing

Local app testing.

Risk

Minimal

Microsoft Reviewers: Open in CodeFlow

@Copilot Copilot AI review requested due to automatic review settings June 27, 2025 10:32
@dipeshmsft dipeshmsft requested a review from a team as a code owner June 27, 2025 10:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes low visibility of DataGrid column header text in high contrast mode by introducing a new resource, DataGridColumnHeaderForeground, and using it in multiple theme files.

  • Introduces a new SolidColorBrush resource for DataGridColumnHeaderForeground in several theme files.
  • Applies the new resource via a Setter in the DefaultDataGridColumnHeaderStyle in each theme.
  • Updates both HC and conventional themes to use the new color resource ensuring consistent visibility across modes.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Fluent.xaml Adds a Foreground Setter referencing the new resource in the default DataGridColumnHeader style.
Fluent.Light.xaml Introduces the DataGridColumnHeaderForeground brush and applies it via the style.
Fluent.HC.xaml Defines the HC-specific DataGridColumnHeaderForeground brush and updates the header style accordingly.
Fluent.Dark.xaml Adds the new Foreground Setter and brush for Dark theme.
DataGrid.xaml Updates the DataGrid header style to use the dynamic resource for Foreground.
Theme/Light.xaml Adds the brush definition for DataGridColumnHeaderForeground in Light theme resources.
Theme/HC.xaml Updates HC theme resources with the new brush definition.
Theme/Dark.xaml Inserts the new brush definition for Dark theme resources.
Comments suppressed due to low confidence (2)

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml:407

  • Add tests to verify that the DataGrid column header renders with the correct foreground color in both normal and high contrast modes. This will help ensure that the fix consistently improves header visibility across themes.
        <Setter Property="Foreground" Value="{DynamicResource DataGridColumnHeaderForeground}" />

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.HC.xaml:373

  • Ensure that the SystemColorButtonTextColor used for DataGridColumnHeaderForeground in HC mode provides sufficient contrast for accessibility guidelines. Consider validating this color choice against accessibility standards.
  <SolidColorBrush x:Key="DataGridColumnHeaderForeground" Color="{StaticResource SystemColorButtonTextColor}" />

@dotnet-policy-service dotnet-policy-service bot added the PR metadata: Label to tag PRs, to facilitate with triage label Jun 27, 2025
Copy link

codecov bot commented Jun 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 13.45748%. Comparing base (28843aa) to head (871759f).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10956         +/-   ##
===================================================
- Coverage   13.52892%   13.45748%   -0.07144%     
===================================================
  Files           3319        3319                 
  Lines         664894      664894                 
  Branches       74674       74674                 
===================================================
- Hits           89953       89478        -475     
- Misses        572398      572864        +466     
- Partials        2543        2552          +9     
Flag Coverage Δ
Debug 13.45748% <ø> (-0.07144%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant