覆盖主题画笔 Windows 10 UWP [英] Override theme brush Windows 10 UWP

查看:32
本文介绍了覆盖主题画笔 Windows 10 UWP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖 Windows 10 中的一些样式颜色,但我无法使其正常工作.

I'm trying to override some style-colors in Windows 10 but I cannot get it to work.

我的 app.xaml 如下所示:

My app.xaml looks like this:

        <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 看起来像这样

And my Theme.xaml looks like this

<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"/>

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

However it doesn't work, it doesn't override the style anywhere.

推荐答案

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

The styles you are setting are for Windows 8 apps. The styles used by Universal Windows apps are greatly simplified.

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

The easiest way to find them is to add your ListBox to a page, right click on it in the designer, and select Edit Template... Create a copy of the template and look at the names used.

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

All of the controls now use the same brushes when possible rather than having control-specific ones.

例如,ListBox 为其前景、背景和边界刷使用以下画笔:

For example, the ListBox uses the following brushes for its Foreground, Background, and BorderBrush:

  • SystemControlForegroundBaseHighBrush
  • SystemControlBackgroundChromeMediumLowBrush
  • SystemControlForegroundBaseHighBrush

这篇关于覆盖主题画笔 Windows 10 UWP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆