AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.14k stars 2.26k forks source link

Theme variant behaves abnormally #17351

Open lxy-iUnknown opened 1 month ago

lxy-iUnknown commented 1 month ago

Describe the bug

Theme variant in behaves abnormally on non-English Windows when high contrast themes are enabled

To Reproduce

  1. Running on a non-English Windows / Change the display language
  2. Goto Windows settings > Accessibility > Contrast themes
  3. Select "Desert" theme and apply
  4. Create and run a simple Avalonia app, the background is black TestApp_kI7RBZOFLz Sample code: TestApp.zip

Expected behavior

Background of this app should be white

Avalonia version

11.1.0

OS

Windows

Additional context

Root cause: the name of Windows.UI.ViewManagement.AccessibilitySettings.HighContrastScheme is localized See: high contrast - UWP HighContrastScheme check in localized environment - Stack Overflow

https://github.com/AvaloniaUI/Avalonia/blob/b5fd40e5046805c1fa072ae702a2a5ef87c3ee64/src/Windows/Avalonia.Win32/Win32PlatformSettings.cs#L59-L61

When in high contrast mode, the actual theme variant should be determined by the RGB values of accent color

https://github.com/AvaloniaUI/Avalonia/blob/b5fd40e5046805c1fa072ae702a2a5ef87c3ee64/src/Windows/Avalonia.Win32/Win32PlatformSettings.cs#L72-L74