我想在应用程序级别更改焦点视觉属性。(如邮件应用程序)。 根据Focus Visual Docucmentation ,可以通过更改相应的系统画笔资源来更改应用程序级别的主要和次要边框颜色。
There are only two color properties for the focus visuals: the primary border color, and the secondary border color. These focus visual border colors can be changed per-control on an page level, and globally on an app-wide level:
To brand focus visuals app-wide, override the system brushes:
<SolidColorBrush x:Key="SystemControlFocusVisualPrimaryBrush" Color="DarkRed"/> <SolidColorBrush x:Key="SystemControlFocusVisualSecondaryBrush" Color="Pink"/>
但是文档中没有提供焦点视觉的厚度。是否有任何可用资源或任何其他方式来指定应用程序级别的厚度?
最佳答案
不幸的是,没有用于主要和次要系统焦点视觉效果的此类资源。但是假设您使用控件的默认样式,您可以尝试定义一个基本样式,然后让您需要焦点视觉的所有控件都继承它。
您甚至可以在基本样式中定义颜色和边距,这样您就可以在一个集中位置来管理所有全局焦点样式。
<Style x:Name="DefaultFrameworkElementStyle" TargetType="FrameworkElement">
<Setter Property="FocusVisualPrimaryThickness" Value="4" />
<Setter Property="FocusVisualSecondaryThickness" Value="2" />
<Setter Property="FocusVisualPrimaryBrush" Value="DarkRed" />
<Setter Property="FocusVisualSecondaryBrush" Value="Red" />
<Setter Property="FocusVisualMargin" Value="2" />
</Style>
<Style TargetType="Button" BasedOn="{StaticResource DefaultFrameworkElementStyle}" />
<Style TargetType="ListViewItem" BasedOn="{StaticResource DefaultFrameworkElementStyle}" />
关于xaml - 在 UWP 中的应用程序级别调整焦点视觉属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44363279/