![](/img/trans.png)
[英]Change 1px border color to custom color instead of accent color in Windows 10
[英]Change Accent Color in Windows 10 UWP
我真的不想在我的应用程序中使用用户在Windows中选择的强调色,而是希望拥有自己的色彩显示。 我可以通过制作新样式手动更改所有项目,但它只是在普通控件中的很多地方,在应用程序级别上做的很好。
我尝试设置<SolidColorBrush x:Key="SystemAccentColor" Color="#FFCB2128" />
但由于某些原因,注意某些项目并将其他像视频控件变为灰色。
在Win10 UWP上,System Accent颜色定义为ThemeResource SystemControlHighlightAccentBrush
。 您可以按以下方式覆盖它。
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Orange" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Green" />
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Blue" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
要更改每个系统控件上的重音颜色,您必须重新定义系统资源,如下所示。
请注意, SystemAccentColor
是一种颜色,而不是画笔 。 如果不重新定义所有其他画笔,则不会对所有画笔应用颜色。
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<Color x:Key="SystemAccentColor">#FF20A060</Color> <!--Your accent color-->
<SolidColorBrush x:Key="SystemControlBackgroundAccentBrush" Color="{ThemeResource SystemAccentColor}" />
<SolidColorBrush x:Key="SystemControlDisabledAccentBrush" Color="{ThemeResource SystemAccentColor}" />
<SolidColorBrush x:Key="SystemControlForegroundAccentBrush" Color="{ThemeResource SystemAccentColor}" />
<SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="{ThemeResource SystemAccentColor}" />
<SolidColorBrush x:Key="SystemControlHighlightAltAccentBrush" Color="{ThemeResource SystemAccentColor}" />
<SolidColorBrush x:Key="SystemControlHighlightAltListAccentHighBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.9" />
<SolidColorBrush x:Key="SystemControlHighlightAltListAccentLowBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.6" />
<SolidColorBrush x:Key="SystemControlHighlightAltListAccentMediumBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.8" />
<SolidColorBrush x:Key="SystemControlHighlightListAccentHighBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.9" />
<SolidColorBrush x:Key="SystemControlHighlightListAccentLowBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.6" />
<SolidColorBrush x:Key="SystemControlHighlightListAccentMediumBrush" Color="{ThemeResource SystemAccentColor}" Opacity="0.8" />
<SolidColorBrush x:Key="SystemControlHyperlinkTextBrush" Color="{ThemeResource SystemAccentColor}" />
<SolidColorBrush x:Key="ContentDialogBorderThemeBrush" Color="{ThemeResource SystemAccentColor}" />
<SolidColorBrush x:Key="JumpListDefaultEnabledBackground" Color="{ThemeResource SystemAccentColor}" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
如果您没有使用任何模板或ResourceDictionaries,请将以下内容添加到App.xaml:
<ResourceDictionary>
<Color x:Key="SystemAccentColor">#FFCB2128</Color>
</ResourceDictionary>
如果您使用的是Minimal Template10模板,请在CustomColor和ContrastColor值之后将以下行添加到Styles / Custom.xaml:
<Color x:Key="SystemAccentColor">#FFCB2128</Color>
如果您在其他地方拥有自己的ResourceDictionary,从App.xaml链接,那么同样在那里添加“Color”行。
对我有用的是设定
<SolidColorBrush x:Key="SystemAccentColor" Color="#FFCB2128" />
<Color x:Key="SystemAltHighColor">#FFCB2128</Color>
<Color x:Key="SystemAltLowColor">#FFCB2128</Color>
<Color x:Key="SystemAltMediumColor">#FFCB2128</Color>
<Color x:Key="SystemAltMediumHighColor">#FFCB2128</Color>
<Color x:Key="SystemAltMediumLowColor">#FFCB2128</Color>
<Color x:Key="SystemBaseHighColor">#FFCB2128</Color>
<Color x:Key="SystemBaseLowColor">#FFCB2128</Color>
<Color x:Key="SystemBaseMediumColor">#FFCB2128</Color>
<Color x:Key="SystemBaseMediumHighColor">#FFCB2128</Color>
<Color x:Key="SystemBaseMediumLowColor">#FFCB2128</Color>
在app.xaml文件中,为了覆盖windows设置的onese。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.