Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinUI 3 turns on immersive dark mode even if the app is in light mode if Window.ExtendsContentIntoTitleBar is true #8377

Open
BreeceW opened this issue Apr 9, 2023 · 0 comments
Labels
area-Windowing bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team

Comments

@BreeceW
Copy link
Contributor

BreeceW commented Apr 9, 2023

Describe the bug

If Window.ExtendsContentIntoTitleBar == true, WinUI 3 appears to set the DWMWA_USE_IMMERSIVE_DARK_MODE attribute to true. This results in the window gaining a darker shadow. This is good if your app is using dark mode, however, it sets the attribute even in light mode.

Steps to reproduce the bug

Make a window that sets Window.ExtendsContentIntoTitleBar to true. With your system in light mode, observe that the shadow is darker than other Windows apps that are in light mode. You can also toggle immersive dark mode with DwmSetWindowAttribute yourself and see how this is impacting the shadow.

Expected behavior

DWMWA_USE_IMMERSIVE_DARK_MODE should be set to true only when the app is in dark mode. The expected behavior is light mode gets a small window shadow, and dark mode gets a big window shadow.

Screenshots

ExtendsContentIntoTitleBar off in light mode gives small shadow (good). ExtendsContentIntoTitleBar on in light mode gives heavy shadow (bad).

NuGet package version

WinUI 3 - Windows App SDK 1.2.5: 1.2.230313.1

Windows version

Windows 11 (22H2): Build 22621

Additional context

This issue is similar to (and sort of the opposite of) #8376. In that issue, which assumes you are not using Window.ExtendsContentIntoTitleBar, immersive dark mode is never set, even though it needs to be in dark mode. This issue is the opposite: as long as Window.ExtendsContentIntoTitleBar is on, immersive dark mode is always turned on, even when it shouldn’t be (when the app is in light mode). This issue is similar to #7131 but deals specifically with the shadow and immersive dark mode.

There is a workaround. I would suggest avoiding Window.ExtendsContentIntoTitleBar and using AppWindowTitleBar.ExtendsContentIntoTitleBar instead. However, you can use DwmSetWindowAttribute(WindowNative.GetWindowHandle(this), DWMWA_USE_IMMERSIVE_DARK_MODE, ...) to turn off immersive dark mode when the app is in light mode, which fixes the shadow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windowing bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests

2 participants