Change default dark background in UWP

时光怂恿深爱的人放手 提交于 2019-12-07 15:28:47

问题


I'm trying to change default black background to #111. Here is the code that i tried to use

    <ResourceDictionary x:Key="Dark">

        ...

        <Color x:Key="SystemAltHighColor">#111</Color>
        <SolidColorBrush x:Key="SystemAltHighColorBrush" Color="{StaticResource SystemAltHighColor}"/>
        ...

    </ResourceDictionary>

But it doesn't work. What i'm doing wrong?


回答1:


SystemAltHighColorBrush is not a used brush in Windows 10 UWP. You can double check all used resources at the following path:

C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.10240.0\Generic\generic.xaml

If you mean the application's page background, you're looking for ApplicationPageBackgroundThemeBrush as this is the default style used on each new page.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

You're trying to change theme resources (they differ between dark and light), so your change should reflect this. Override the theme dictionaries with the appropriate keys. As #111111 is very close to black, I took a fancy green for demo purposes.

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Default">
                <Color x:Key="SystemAltHighColor">#11CC11</Color>
                <SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="{ThemeResource SystemAltHighColor}" />
            </ResourceDictionary>
            <ResourceDictionary x:Key="Dark">
                <Color x:Key="SystemAltHighColor">#11CC11</Color>
                <SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="{ThemeResource SystemAltHighColor}" />
            </ResourceDictionary>
        </ResourceDictionary.ThemeDictionaries>
    </ResourceDictionary>
</Application.Resources>


来源:https://stackoverflow.com/questions/33876280/change-default-dark-background-in-uwp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!