我试图在
Windows 10中覆盖一些样式颜色,但我无法让它工作.
我的app.xaml看起来像这样:
<ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources.xaml"/> </ResourceDictionary.MergedDictionaries> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default" Source="Theme.xaml"/> </ResourceDictionary.ThemeDictionaries> </ResourceDictionary> </Application.Resources>
而我的Theme.xaml看起来像这样
<ResourceDictionary x:Key="Default" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <SolidColorBrush x:Key="ListBoxBackgroundThemeBrush" Color="Transparent" /> <SolidColorBrush x:Key="ListBoxFocusBackgroundThemeBrush" Color="Transparent" /> <SolidColorBrush x:Key="ListBoxItemPressedBackgroundThemeBrush" Color="Transparent" /> <SolidColorBrush x:Key="ListBoxItemSelectedForegroundThemeBrush" Color="Transparent" /> <SolidColorBrush x:Key="ListBoxItemSelectedBackgroundThemeBrush" Color="Transparent" /> <SolidColorBrush x:Key="FocusVisualBlackStrokeThemeBrush" Color="Transparent" /> <SolidColorBrush x:Key="ScrollBarButtonForegroundThemeBrush" Color="Red" /> <SolidColorBrush x:Key="ScrollBarPanningBackgroundThemeBrush" Color="Red" /> <SolidColorBrush x:Key="ButtonPressedBackgroundThemeBrush" Color="White"/> <SolidColorBrush x:Key="SearchBoxHitHighlightSelectedForegroundThemeBrush" Color="Red"/> <SolidColorBrush x:Key="SearchBoxHitHighlightForegroundThemeBrush" Color="Pink"/>
但是它不起作用,它不会覆盖任何地方的风格.
您设置的样式适用于Windows 8应用程序.通用Windows应用程序使用的样式大大简化.
找到它们的最简单的方法是将您的ListBox添加到页面,在设计器中右键单击它,然后选择编辑模板…创建模板的副本并查看使用的名称.
所有的控件现在都可以使用相同的画笔,而不是具有特定的控件.
例如,ListBox为其前景,背景和BorderBrush使用以下画笔:
> SystemControlForegroundBaseHighBrush> SystemControlBackgroundChromeMediumLowBrush> SystemControlForegroundBaseHighBrush