[UWP] [C++] How do I set theme as system default?

Eric Tian 211 Reputation points


I'm trying to create an app setting in c++ uwp and it has three radio buttons: "Light" "Dark" and "System Default". How do get the system default (light, dark, etc.) when I initialize the app? Thank you.

Universal Windows Platform (UWP)
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
2,633 questions
No comments
{count} votes

Accepted answer
  1. Eric Tian 211 Reputation points

    Save "System Theme" to app data and on app initialization, do this:

    auto DefaultTheme = ref new Windows::UI::ViewManagement::UISettings();
    auto uiTheme = DefaultTheme->GetColorValue(Windows::UI::ViewManagement::UIColorType::Background).ToString();
    if (uiTheme == "#FF000000")
        App::Current->RequestedTheme = ApplicationTheme::Dark;
    else if (uiTheme == "#FFFFFFFF")
        App::Current->RequestedTheme = ApplicationTheme::Light;

0 additional answers

Sort by: Most helpful