Search code examples
c#windowsxamlwin-universal-appwindows-8.1-universal

Why the default windows 8 universal app created in VS 2015 has a dark background


I'm creating a windows 8 universal app using C# in Visual Studio 2015. I followed this path to create an empty project: Visual C#->Windows->Windows 8->Universal->Blank App(Universal Windows 8.1).

I'm surprised to find out that the empty app start with black background and white foreground. Is there any particular reason why Microsoft does this?

enter image description here

Also, is there any elegant way to change the background and foreground color? I was able to do it by changing the following config in the MainPage.xaml file:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"></Grid>

To:

<Grid Background="White"></Grid>

But I wasn't able to change the foreground, and if I add a button to the window, the button text cannot be seen on a white background because the button foreground is white. (As far as I know, all the children components will inherit the background color or the foreground color depending all what kind of components they are.)

Any clarification is appreciated.


Solution

  • See the Remarks on the Application.RequestedTheme property on MSDN:

    There are two built in themes: "Light" and "Dark". By default your app runs using the "Dark" theme (in the themeresources.xaml file, the key name for the "Dark" resources is "Default"). You can set the app's RequestedTheme property to specify which theme is used.

    So setting

    <Application ... RequestedTheme="Light">
    

    in your App.xaml makes your application use the Light theme.