microsoft / microsoft/WindowsAppSDK

Feature Request: API to set dark mode for Win32 controls

Open
#5,543 0 comments 4 reactions 0 assignees View on GitHub
feature proposal
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

To this date, Win32 controls are always rendered in light mode, even if dark mode is enabled.

The functionality to render Win32 controls in dark is already mostly available, but undocumented, as mentioned in #5476 "Dark mode for applications":

> Also, there exists other APIs in `uxtheme.dll` which might be of interest for people transitioning to WinUI and/or XAML islands:
>
> * `SetPreferredAppMode`:
>
> * This allows apps to enable dark theme support for Win32 controls. This is notably used by Windows Explorer for its dark theme.
> * `AllowDarkModeForWindow`:
>
> * Once the app mode is set to `AllowDark` using the API above, it is a per-window opt-in.
> * Once this method is called, the Win32 controls in the window uses dark theme if the system dark theme is enabled, and automatically switches to light theme when the user changes their settings.
> * Note that some controls might need to have their theme manually set to `DarkMode_Explorer` for this to be effective
> * Dark mode ribbon can be opt-in with the window property `UI_PKEY_DarkModeRibbon`
>
> Those methods are useful because when transitioning, it allows developers to use a dark theme for old controls and new controls alike, to get a somewhat consistent UI. Darkening Win32 or winforms controls manually is extremely hard to get right, and leveraging the work done in Windows Explorer would prevent a lot of misdirected attempts at dark theming Win32 controls.

One area where this is especially noticeable for almost every app is the context menu that appears when right clicking on the title bar.

There was already an issue on GitHub, #5476 "Dark mode for applications", but it was closed even though the issue is not yet resolved. I am opening this issue to avoid the issue getting lost.

Contributor guide

No contributing guide indexed for this repository

Research direction

No implementation files or tests are named. Start by reviewing the referenced #5476 discussion and the documented behavior of SetPreferredAppMode and AllowDarkModeForWindow; done means Windows App SDK exposes a supported way for applications to opt Win32 controls into system dark mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.