xaml – 覆盖主题画笔Windows 10 UWP

前端之家收集整理的这篇文章主要介绍了xaml – 覆盖主题画笔Windows 10 UWP前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在 Windows 10中覆盖一些样式颜色,但我无法让它工作.

我的app.xaml看起来像这样:

  1. <ResourceDictionary>
  2. <ResourceDictionary.MergedDictionaries>
  3. <ResourceDictionary Source="Resources.xaml"/>
  4. </ResourceDictionary.MergedDictionaries>
  5. <ResourceDictionary.ThemeDictionaries>
  6. <ResourceDictionary x:Key="Default" Source="Theme.xaml"/>
  7. </ResourceDictionary.ThemeDictionaries>
  8. </ResourceDictionary>
  9. </Application.Resources>

而我的Theme.xaml看起来像这样

  1. <ResourceDictionary
  2. x:Key="Default"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  5.  
  6. <SolidColorBrush x:Key="ListBoxBackgroundThemeBrush" Color="Transparent" />
  7. <SolidColorBrush x:Key="ListBoxFocusBackgroundThemeBrush" Color="Transparent" />
  8. <SolidColorBrush x:Key="ListBoxItemPressedBackgroundThemeBrush" Color="Transparent" />
  9. <SolidColorBrush x:Key="ListBoxItemSelectedForegroundThemeBrush" Color="Transparent" />
  10. <SolidColorBrush x:Key="ListBoxItemSelectedBackgroundThemeBrush" Color="Transparent" />
  11. <SolidColorBrush x:Key="FocusVisualBlackStrokeThemeBrush" Color="Transparent" />
  12. <SolidColorBrush x:Key="ScrollBarButtonForegroundThemeBrush" Color="Red" />
  13. <SolidColorBrush x:Key="ScrollBarPanningBackgroundThemeBrush" Color="Red" />
  14. <SolidColorBrush x:Key="ButtonPressedBackgroundThemeBrush" Color="White"/>
  15.  
  16. <SolidColorBrush x:Key="SearchBoxHitHighlightSelectedForegroundThemeBrush" Color="Red"/>
  17. <SolidColorBrush x:Key="SearchBoxHitHighlightForegroundThemeBrush" Color="Pink"/>

但是它不起作用,它不会覆盖任何地方的风格.

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

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

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

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

> SystemControlForegroundBaseHighBrush> SystemControlBackgroundChromeMediumLowBrush> SystemControlForegroundBaseHighBrush

猜你在找的Windows相关文章