microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.39k stars 683 forks source link

When changing the application theme using RequestedTheme, the colors of the toolbar buttons in the TitleBar do not change properly. #9722

Open LexeyLex opened 5 months ago

LexeyLex commented 5 months ago

Describe the bug

When I change the application theme to another in code, the buttons in the toolbar (Close, Collapse, Maximize) remain with the style of the previous theme.

Steps to reproduce the bug

  1. Create new Empty WinUI app
  2. Add theme change code: ((FrameworkElement)Content.XamlRoot.Content).RequestedTheme = ElementTheme.Light;
  3. Start the app
  4. See how the colors of the buttons in the toolbar do not change properly, but remain the color of the previous theme

Expected behavior

Toolbar button colors should change appropriately to match the theme of the entire program

Screenshots

image image

NuGet package version

WinUI 3 - Windows App SDK 1.5.4: 1.5.240607001

Windows version

Windows 11 (22H2): Build 22621

Additional context

All other colors change perfectly

ranjeshj commented 5 months ago

Application.RequestedTheme needs to handle this scenario. WinUIGallery works around this issue (not ideal) but you can see how it is done there.