Do you have to adjust WinUI3 controls for Light and Dark Mode yourself?

youki 1,021 Reputation points
2023-08-17T22:42:42.8833333+00:00

I thought I'd give this a try and see how light and dark mode affects a WinUI3 application and the controls.

For example, the contrast is better for some things and worse for others (combo boxes, buttons etc.), depending on whether it's light or dark mode.

With the NavigationView (LeftCompact), for example, there is no color difference or outlines at all, it does not stand out at all as you know it from other applications.

Does that mean that you have to adjust everything yourself or am I missing something?

Windows development | Windows App SDK
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2023-08-18T01:50:49.9933333+00:00

    Hello @youki,

    Yes, you have to adjust everything yourself. And they are predefined separately. Dark, Light, HighContrast. Like

    <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Dark">
    
            </ResourceDictionary>
    
            <ResourceDictionary x:Key="Light">
    
            </ResourceDictionary>
    
            <ResourceDictionary x:Key="HighContrast">
    
            </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>
    

    See Guidelines for custom theme resources for more information.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2023-08-18T08:01:55.88+00:00

    See Application.RequestedTheme

    Test with a StackPanel :

    SwitchTheme

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.