microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.84k stars 320 forks source link

Apps use the wrong theme for the system context menu #2943

Open Balkoth opened 2 years ago

Balkoth commented 2 years ago

Describe the bug

Apps on a system that is configured to use the dark theme use the light system context menu theme:

Context menu looks like this:

image

When it should look like this:

image

Steps to reproduce the bug

Create a new project on a system that is configured to use dark mode.

Expected behavior

No response

Screenshots

No response

NuGet package version

1.1.4

Packaging type

Packaged (MSIX), Unpackaged

Windows version

Windows 10 version 21H2 (19044, November 2021 Update)

IDE

Visual Studio 2022

Additional context

The right theme for the context menue is chosen when you call into an undocumented function in uxtheme.dll:

[DllImport("uxtheme.dll", EntryPoint = "#135", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern int SetPreferredAppMode(int preferredAppMode);

According to this there are a number of values for the int parameter.

Call this function on program start to choose the right mode for the current configuration.

castorix commented 2 years ago

It works fine for me (Windows 10 21H1, Windows app SDK 1.1.0) : SetPreferredAppMode

Balkoth commented 2 years ago

The bug is also present in 1.1.5 for me.

@castorix I think you got wrong what i said. If i use SetPreferredAppMode this of course works. But i should not have to use an undocumented function, this should work out of the box.

castorix commented 2 years ago

The bug is also present in 1.1.5 for me.

@castorix I think you got wrong what i said. If i use SetPreferredAppMode this of course works. But i should not have to use an undocumented function, this should work out of the box.

Ah ok. I thought it did not work on Windows 10 21H2 Indeed, we should not have to call undocumented APIs for this

rkarman commented 2 years ago

This is not a bug per se, it is how win32 works today - if you just create a window in a "blank app" in win32 you will get the light theme system menu, this is the same for a WinUI WinAppSDK app.

I do however agree that this does not look good, and at least WinAppSDK apps should properly handle light/dark mode out of the box with no need for developers to do anything special. @MikeHillberg @ryandemopoulos - I think this (theme/mode aware) is something that needs a broader support/investment across components of WinAppSDK.

With that in mind, I'd like to see this converted from a bug into a feature suggestion.

Balkoth commented 2 years ago

Windows explorer says otherwise, it switches to the correct menu theme upon changing from light to dark. Every app that does not reflect this looks buggy to me, so i consider this to be a bug.

sylveon commented 1 year ago

Related: #41

rkarman commented 1 year ago

Since I'm no longer PM:ing this area I'm unassigning me. @MikeHillberg and @ryandemopoulos (who've been assigned for a while as well) will continue to drive this topic.