更改 UWP 中的默认深色背景
Change default dark background in UWP
我正在尝试将默认黑色背景更改为 #111。这是我尝试使用的代码
<ResourceDictionary x:Key="Dark">
...
<Color x:Key="SystemAltHighColor">#111</Color>
<SolidColorBrush x:Key="SystemAltHighColorBrush" Color="{StaticResource SystemAltHighColor}"/>
...
</ResourceDictionary>
但是没用。我做错了什么?
SystemAltHighColorBrush
不是 Windows 10 UWP 中使用的画笔。您可以在以下路径仔细检查所有使用的资源:
C:\Program Files (x86)\Windows
Kits\DesignTime\CommonConfiguration\Neutral\UAP.0.10240.0\Generic\generic.xaml
如果您指的是应用程序的页面背景,您正在寻找 ApplicationPageBackgroundThemeBrush
,因为这是每个新页面上使用的默认样式。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
您正在尝试更改主题资源(它们在深色和浅色之间有所不同),因此您的更改应该反映这一点。使用适当的键覆盖主题词典。由于#111111 非常接近黑色,为了演示目的,我选择了绿色。
<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>
我正在尝试将默认黑色背景更改为 #111。这是我尝试使用的代码
<ResourceDictionary x:Key="Dark">
...
<Color x:Key="SystemAltHighColor">#111</Color>
<SolidColorBrush x:Key="SystemAltHighColorBrush" Color="{StaticResource SystemAltHighColor}"/>
...
</ResourceDictionary>
但是没用。我做错了什么?
SystemAltHighColorBrush
不是 Windows 10 UWP 中使用的画笔。您可以在以下路径仔细检查所有使用的资源:
C:\Program Files (x86)\Windows Kits\DesignTime\CommonConfiguration\Neutral\UAP.0.10240.0\Generic\generic.xaml
如果您指的是应用程序的页面背景,您正在寻找 ApplicationPageBackgroundThemeBrush
,因为这是每个新页面上使用的默认样式。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
您正在尝试更改主题资源(它们在深色和浅色之间有所不同),因此您的更改应该反映这一点。使用适当的键覆盖主题词典。由于#111111 非常接近黑色,为了演示目的,我选择了绿色。
<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>