在 UWP 中更改默认深色背景 [英] Change default dark background in UWP
问题描述
我正在尝试将默认黑色背景更改为 #111.这是我尝试使用的代码
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?
推荐答案
SystemAltHighColorBrush
不是 Windows 10 UWP 中使用的画笔.您可以在以下路径中仔细检查所有使用的资源:
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)\WindowsKits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.10240.0\Generic\generic.xaml
C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.10240.0\Generic\generic.xaml
如果您指的是应用程序的页面背景,那么您正在寻找 ApplicationPageBackgroundThemeBrush
,因为这是每个新页面上使用的默认样式.
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}">
您正在尝试更改主题资源(它们在深色和浅色之间有所不同),因此您的更改应反映这一点.使用适当的键覆盖主题词典.由于#111111 非常接近黑色,为了演示目的,我选择了花哨的绿色.
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>
这篇关于在 UWP 中更改默认深色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!