Search code examples
uwpvisual-studio-2022winui-3windows-11

WinUI 3 UWP - Choose appo theme


I'm developing a WinUI 3 UWP app for Windows 11 and the app automatically defaults to the theme chosen by Windows. Is there any way to give the user the choice?


Solution

  • This is how you can change the theme for your whole application:

    if (Window.Current.Content is FrameworkElement rootElement)
    {
        rootElement.RequestedTheme = ElementTheme.Light; //.Dark, .Default
    }