Fix low-contrast de-emphasized text in WPF Gallery under high contrast#787
Open
amarinov-msft wants to merge 1 commit into
Open
Fix low-contrast de-emphasized text in WPF Gallery under high contrast#787amarinov-msft wants to merge 1 commit into
amarinov-msft wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Desertcontrast 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.xamlAdd a shared
DynamicResource,DeemphasizedTextOpacity(0.7), for dimmed text.Sample Applications/WPFGallery/App.xaml.csOverride
DeemphasizedTextOpacityto 1.0 whenSystemParameters.HighContrastis set, and update it live on high-contrast changes.DynamicResourcepushes the new value to every consumer.Sample Applications/WPFGallery/Resources/Templates.xamland 8 view files(Typography, Icons, ListView, User Dashboard, Label, Settings, Geometry, Spacing) route their dimmed-text
Opacitythrough {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 fullWindowTextcolor in any contrast theme.Result
Under high contrast the de-emphasized text now renders at the theme's full
WindowTextcolor, comfortably above the 4.5:1 minimum, so the Accessibility Insights Text Contrast check passes. Normal Light/Dark appearance is unchanged.Testing
Desertcontrast theme (now > 4.5:1).Microsoft Reviewers: Open in CodeFlow