diff --git a/Sample Applications/WPFGallery/App.xaml.cs b/Sample Applications/WPFGallery/App.xaml.cs index 80fe63fc1..7068d0829 100644 --- a/Sample Applications/WPFGallery/App.xaml.cs +++ b/Sample Applications/WPFGallery/App.xaml.cs @@ -1,5 +1,6 @@ using System.Configuration; using System.Data; +using System.Windows; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -153,9 +154,24 @@ public static void Main() App app = new(); app.InitializeComponent(); + app.ApplyDeemphasizedTextOpacity(); app.MainWindow = _host.Services.GetRequiredService(); app.MainWindow.Visibility = Visibility.Visible; app.Run(); } + + // Dimmed text fails the 4.5:1 minimum under some high-contrast themes (e.g. Desert), so render + // de-emphasized text at full opacity there. DynamicResource pushes the change to every consumer. + private void ApplyDeemphasizedTextOpacity() + { + Resources["DeemphasizedTextOpacity"] = SystemParameters.HighContrast ? 1.0 : 0.7; + SystemParameters.StaticPropertyChanged += (_, e) => + { + if (e.PropertyName == nameof(SystemParameters.HighContrast)) + { + Resources["DeemphasizedTextOpacity"] = SystemParameters.HighContrast ? 1.0 : 0.7; + } + }; + } } diff --git a/Sample Applications/WPFGallery/Resources/PageStyles.xaml b/Sample Applications/WPFGallery/Resources/PageStyles.xaml index 53e2a0493..a3670c687 100644 --- a/Sample Applications/WPFGallery/Resources/PageStyles.xaml +++ b/Sample Applications/WPFGallery/Resources/PageStyles.xaml @@ -16,6 +16,10 @@ 40 68 + + 0.7 + diff --git a/Sample Applications/WPFGallery/Views/DesignGuidance/SpacingPage.xaml b/Sample Applications/WPFGallery/Views/DesignGuidance/SpacingPage.xaml index ac48b5bf7..c83285fec 100644 --- a/Sample Applications/WPFGallery/Views/DesignGuidance/SpacingPage.xaml +++ b/Sample Applications/WPFGallery/Views/DesignGuidance/SpacingPage.xaml @@ -83,13 +83,13 @@ diff --git a/Sample Applications/WPFGallery/Views/DesignGuidance/TypographyPage.xaml b/Sample Applications/WPFGallery/Views/DesignGuidance/TypographyPage.xaml index 1e618f900..163de81a1 100644 --- a/Sample Applications/WPFGallery/Views/DesignGuidance/TypographyPage.xaml +++ b/Sample Applications/WPFGallery/Views/DesignGuidance/TypographyPage.xaml @@ -1,4 +1,4 @@ - diff --git a/Sample Applications/WPFGallery/Views/Samples/UserDashboardPage.xaml b/Sample Applications/WPFGallery/Views/Samples/UserDashboardPage.xaml index b115279d1..16daf9313 100644 --- a/Sample Applications/WPFGallery/Views/Samples/UserDashboardPage.xaml +++ b/Sample Applications/WPFGallery/Views/Samples/UserDashboardPage.xaml @@ -1,4 +1,4 @@ - @@ -91,7 +91,7 @@ Grid.Column="1" Margin="12,0,0,6" Foreground="{DynamicResource TextFillColorPrimaryBrush}" - Opacity="0.8" + Opacity="{DynamicResource DeemphasizedTextOpacity}" Text="{Binding Company, Mode=OneWay}" /> diff --git a/Sample Applications/WPFGallery/Views/SettingsPage.xaml b/Sample Applications/WPFGallery/Views/SettingsPage.xaml index 034132112..b8ea32de7 100644 --- a/Sample Applications/WPFGallery/Views/SettingsPage.xaml +++ b/Sample Applications/WPFGallery/Views/SettingsPage.xaml @@ -1,4 +1,4 @@ - - Select which app theme to display + Select which app theme to display @@ -93,7 +93,7 @@ Margin="12" Orientation="Vertical"> - © 2025 Microsoft. All rights reserved. + © 2025 Microsoft. All rights reserved. diff --git a/Sample Applications/WPFGallery/Views/Text/LabelPage.xaml b/Sample Applications/WPFGallery/Views/Text/LabelPage.xaml index 62d5052db..ceeb05e15 100644 --- a/Sample Applications/WPFGallery/Views/Text/LabelPage.xaml +++ b/Sample Applications/WPFGallery/Views/Text/LabelPage.xaml @@ -1,4 +1,4 @@ -