microsoft / microsoft/WindowsAppSDK

Apps use the wrong theme for the system context menu

Open
#2,943 8 comments 1 reaction 2 assignees Assigned to @ryandemopoulos View on GitHub
feature proposal
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### 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:

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

According to [this](https://github.com/ysc3839/win32-darkmode/blob/cc26549b65b25d6f3168a80238792545bd401271/win32-darkmode/DarkMode.h#L11) 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.