Skip to content

Fix low-contrast de-emphasized text in WPF Gallery under high contrast#787

Open
amarinov-msft wants to merge 1 commit into
microsoft:mainfrom
amarinov-msft:amarinov/desert-mode
Open

Fix low-contrast de-emphasized text in WPF Gallery under high contrast#787
amarinov-msft wants to merge 1 commit into
microsoft:mainfrom
amarinov-msft:amarinov/desert-mode

Conversation

@amarinov-msft

@amarinov-msft amarinov-msft commented Jun 26, 2026

Copy link
Copy Markdown

Summary
Fixes an accessibility issue in the WPF Gallery. De-emphasized "caption/label" text (column headers, form labels, page-button descriptions, list secondary text, settings captions) rendered below the 4.5:1 minimum required by MAS 4.3.1 under the Desert contrast theme,and is flagged by Accessibility Insights across multiple pages. The app dims this text by applying a hardcoded ~0.7 Opacity over the primary text brush. In normal and Aquatic themes the resulting gray passes, but Desert's WindowText / background pair is borderline, so the dimmed text drops under 4.5:1. The same pattern is used throughout the app, so the issue recurs on many pages.

Change
Sample Applications/WPFGallery/Resources/PageStyles.xaml
Add a shared DynamicResource, DeemphasizedTextOpacity (0.7), for dimmed text.

Sample Applications/WPFGallery/App.xaml.cs
Override DeemphasizedTextOpacity to 1.0 when SystemParameters.HighContrast is set, and update it live on high-contrast changes. DynamicResource pushes the new value to every consumer.

Sample Applications/WPFGallery/Resources/Templates.xaml and 8 view files
(Typography, Icons, ListView, User Dashboard, Label, Settings, Geometry, Spacing) route their dimmed-text Opacity through {DynamicResource DeemphasizedTextOpacity} instead of a hardcoded literal. Because the lever is the opacity itself, the text keeps its primary brush (no color change) and looks identical in normal mode, while rendering at the theme's full WindowText color in any contrast theme.

Result
Under high contrast the de-emphasized text now renders at the theme's full WindowText color, comfortably above the 4.5:1 minimum, so the Accessibility Insights Text Contrast check passes. Normal Light/Dark appearance is unchanged.

Testing

  • Built WPFGallery.csproj (0 errors).
  • Verified all 7 reported pages with the accessibility tools under the Desert contrast theme (now > 4.5:1).
  • Confirmed normal Light and Dark appearance is unchanged.
Microsoft Reviewers: Open in CodeFlow

Dimmed caption/label text (rendered via a hardcoded ~0.7 Opacity over the
primary text brush) fell below the 4.5:1 minimum under the Desert contrast
theme (MAS 4.3.1), flagged across multiple pages by Accessibility Insights.

Route the de-emphasis opacity through a new DynamicResource
'DeemphasizedTextOpacity' and override it to 1.0 in App when
SystemParameters.HighContrast is set, so dimmed text renders at full
contrast in any contrast theme while staying unchanged in normal mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant