DefaultTitleBarShouldMatchAppModeTheme does not respect RequestedTheme
Describe the bug
AppWindow.DefaultTitleBarShouldMatchAppModeTheme does not respect the Application.RequestedTheme (or ((FrameworkElement)XamlRoot.Content).RequestedTheme) settings.
The title bar color would then still not match the actual theme used in the app.
Steps to reproduce the bug
- Switch Windows app mode theme to "Dark"
- Set
AppWindow.DefaultTitleBarShouldMatchAppModeTheme = truein theMainWindow - Set
RequestedTheme = ApplicationTheme.Lightin theApp ctorOR((FrameworkElement)Content.XamlRoot.Content).RequestedTheme = ElementTheme.Lightin theMainWindow - Start the app
- See a dark title bar, while the app is in light mode
Expected behavior
See a light title bar, while the app is in light mode
Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.6 Experimental 1: 1.6.240531000-experimental1
Windows version
Windows 11 (22H2): Build 22621
Additional context
This means it is not possible to dynamically switch the title bar color, based on the selection of the user in the app. Most apps offer this kind of setting (even Microsoft apps like Paint), meaning the DefaultTitleBarShouldMatchAppModeTheme will not fit their needs and still require custom code. An additional annoyance is, that RequestedTheme cannot be set at runtime, only in the App ctor (#4474).
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!
Closed similar issues:
- Changing the theme on runtime while no backdrop is set, will not apply the correct colors (#8249), similarity score: 0.80
- [WinUI 3] Changing the theme of the NavigationView doesn't work as expected (#6938), similarity score: 0.77
- Xaml island: Setting "RequestedTheme" results in broken theming and unreadable text when value differs from system-wide setting (#3576), similarity score: 0.77
- Window titlebar controls do not respect users' theme and settings (#9166), similarity score: 0.76
- RequestedTheme changes are not applied properly to StackPanel and ContentDialog in WinUI 3 Desktop (#5788), similarity score: 0.76
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
@codendone i tested with v1.6-exp2 and it seems that this issue fixed. so i think this issue can be closed
@ghost1372 I tested as well with v1.6-exp2, and it's not fixed for me.
@hiteshkrmsft Please reopen the issue, as it is not fixed with v1.7-exp2. I can still reproduce it.
@lolametro This issue was closed via a script mirroring state of the internal bug. Looking at the internal bug, this was resolved because this API has been removed and replaced with something a little different. The new API will be available in the next 1.7 release.
The new AppWindow.AppWindowTitleBar.PreferredTheme property in 1.7 with a TitleBarTheme enum of Default, UseDefaultAppMode, Light, Dark resolves the issue 👌