停用全球FocusVisualStyle [英] Deactivate FocusVisualStyle globally

查看:255
本文介绍了停用全球FocusVisualStyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在全球范围内我的WPF应用程序禁用焦点矩形。对于可以通过

I want to globally deactivate the focus rectangles in my WPF application. For single controls that can be done via

<Style TargetType="Button">
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
</Style>



但如何将它应用到所有的控件在我的应用程序。当应用到FrameworkElement的什么也没有发生。事先我需要的是类似适用于类x和所有派生类。

but how to apply it to all controls in my application. When applying to FrameworkElement nothing happens. What I need would be something like "apply to class x and all derived classes".

谢谢,

斯特凡

推荐答案

据的 http://msdn.microsoft.com/en-us/library/bb613567.aspx ,你应该能够设置全局焦点风格是这样的:

According to http://msdn.microsoft.com/en-us/library/bb613567.aspx, you should be able to set global focus style like this:

<Style x:Key="{x:Static SystemParameters.FocusVisualStyleKey}">
  <Setter Property="Control.Template">
    <Setter.Value>
      <ControlTemplate>
        <Rectangle StrokeThickness="1"
          Stroke="Black"
          StrokeDashArray="1 2"
          SnapsToDevicePixels="true"/>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style> 



我没有测试过,但我想,当你清空控件模板,这将有效地禁用焦点矩形为整个应用程序(只要你有这种风格在App.xaml中)。

I haven't tested it, but I guess that when you empty the controltemplate, this would effectively disable the focus rectangle for the whole app (provided you include this style in app.xaml).

这篇关于停用全球FocusVisualStyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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