High Contrast doesn't work well by default
See original GitHub issue- .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use
dotnet --info
) .NET 5.0 preview 6 - Windows version: (
winver
) 19041 - Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes/No Haven’t tried/can’t try
- Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc…)? If yes, please file the issue via the instructions here. No
- Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.
Problem description: Text is not visible after enabling High Contrast Mode. This is a regular WPF app using default themes/settings. It is not doing anything special for High Contrast.
Actual behavior: Text is not visible after enabling high contrast mode
Expected behavior: Text should be visible after enabling high contrast mode Minimal repro: Install NuGet Package Explorer from Store (or compile from GitHub at https://github.com/NuGetPackageExplorer/NuGetPackageExplorer)
- Deploy OS.
- Perform Store Updates.
- Install the application from Store.
- Launch the application.
- Enable High contrast mode.
- Observe.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to Fix the Inability to Turn Off High Contrast Mode on ...
Start with basic troubleshooting and use the hotkeys to disable the high contrast theme. Then, update GPU drivers and Windows OS and reinstall ......
Read more >High contrast problem, Windows 10
Turn Off High Contrast Settings and right click on the desktop. Select Personalize and under 'Apply a theme' choose default Windows theme.
Read more >Some settings aren't available in High Contrast mode
There might be many reasons why the High Contrast Mode is not working on your Windows 11/10 computer. Sometimes, third-party themes may prevent...
Read more >The Guide To Windows High Contrast Mode
High Contrast mode is an accessibility feature that changes the look of our website and Windows applications by replacing the color of the ......
Read more >How to use high contrast in Windows 10 and 11
How to enable high contrast themes in Windows 10 · Go to the settings menu · In the search bar, type “high contrast...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@clairernovotny One thing you can also do in your styles, and something we do in WPF, to appropriately differentiate between High Contrast and regular themes is to trigger on
SystemParameters.HighContrast
. WPF uses the Classic theme in all High Contrast scenarios. However, we need to modify various aspects of that theme when in High Contrast. Below is a just a basic trigger that we use in multiple places to do this.https://github.com/dotnet/wpf/blob/707c7256e0dd02f2b4cfa3735d457248c66e8d55/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Classic/Themes/Classic.xaml#L711-L719
So you can have fancier UI for your regular themes (like gradients, specific colors you prefer, etc), but only turn those on when not in High Contrast. That allows you to assume the default WPF colors will do the job and we’ve worked hard to ensure that in a lot of cases.
Also, a great tool you can use to help find accessibility violations (both in colors and automation tree) is the Accessibility Insights tool.
I don’t see how this would be a WPF bug. You are clearly overriding the background of the control to be always white, but you are not overriding the text foreground:
https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/blob/d830786cba9b53dcc54694d60515677a381bee07/PackageExplorer/PackageViewer.xaml#L451
WPF does its job of respecting high contrast and rendering the text white, because the hight contrast background should be black.
Either fix the text color too, or preferably use the control background brush, similarly to how you use the active border brush on the same element. Also note that these resources should be declared as
DynamicResoruce
notStaticResource
so that it changes when the system theme changes.Or did I miss something?