xaml - 在 UWP 中的应用程序级别调整焦点视觉属性

标签 xaml uwp win-universal-app uwp-xaml

我想在应用程序级别更改焦点视觉属性。(如邮件应用程序)。 根据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/

相关文章:

c# - WPF DataTrigger for TextBlock 控制Text

WPF UserControl 在引用项目中找不到 XAML 资源

c# - UWP 窗口导航到(激活的)事件

c# - 使用 Raspberry pi 调用 rest API windows 10 IoT

c# - 如何使用 MVVM 根据 Canvas 大小居中形状

c# - 在 ComboBox 中将 Focus 设置为 Checkbox 以获得键盘控制

c# - "The application does not have the cloud notification capability"在 xbox live 上统一登录

java - 能否将 Java Swing 桌面应用程序转换为 UWP 百年纪念应用程序 (AppX)?

c# - 页面内容不显示在框架中,而是显示页面对象名称

c# - UWP 拉伸(stretch) GridView