覆盖主题画笔Windows 10 UWP

rob*_*rtk 11 xaml windows-phone win-universal-app windows-10

我试图在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>
Run Code Online (Sandbox Code Playgroud)

我的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"/>
Run Code Online (Sandbox Code Playgroud)

但它不起作用,它不会覆盖任何地方的样式.

Rob*_*SFT 6

您设置的样式适用于Windows 8应用程序.Universal Windows应用程序使用的样式大大简化.

找到它们的最简单方法是将ListBox添加到页面中,在设计器中右键单击它,然后选择编辑模板...创建模板的副本并查看使用的名称.

现在,所有控件都使用相同的画笔,而不是具有特定于控件的画笔.

例如,ListBox使用以下画笔作为其前景,背景和BorderBrush:

  • SystemControlForegroundBaseHighBrush
  • SystemControlBackgroundChromeMediumLowBrush
  • SystemControlForegroundBaseHighBrush