在 UWP 中的应用程序级别调整焦点视觉属性
Tweak Focus Visual Properties at app level in UWP
我想在应用程序级别更改焦点视觉属性。(如邮件应用程序)。
根据 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"/>
但是文档中没有提供焦点视觉厚度的相关信息。是否有可用的资源或任何其他方式来指定应用级别的厚度?
遗憾的是,主次系统焦点视觉没有此类资源。但是假设您使用控件的默认样式,您可以尝试定义一个 base 样式,然后让您需要的所有控件都继承它的焦点视觉效果。
您甚至可以在 base 样式中定义颜色和边距,这样您就可以集中管理所有全局焦点样式。
<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}" />
我想在应用程序级别更改焦点视觉属性。(如邮件应用程序)。 根据 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"/>
但是文档中没有提供焦点视觉厚度的相关信息。是否有可用的资源或任何其他方式来指定应用级别的厚度?
遗憾的是,主次系统焦点视觉没有此类资源。但是假设您使用控件的默认样式,您可以尝试定义一个 base 样式,然后让您需要的所有控件都继承它的焦点视觉效果。
您甚至可以在 base 样式中定义颜色和边距,这样您就可以集中管理所有全局焦点样式。
<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}" />