删除UserControl上的焦点矩形 [英] Remove focus rectangle on a UserControl

查看:270
本文介绍了删除UserControl上的焦点矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF用户控件焦点=真。只要用户按下Tab或Alt(特别是Alt + Tab到另一个应用程序时),我的UserControl就会获得一个虚线的点,线边界,又名焦点矩形。如何防止我的UserControl显示焦点矩形?



编辑



事实证明,焦点矩形实际上并没有被我的UserControl显示出来。 My Focusable UserControl包含另一个UserControl,它包含一个ItemsControl,而ItemsControl则显示了焦点矩形。当我添加FocusVisualStyle ={x:如果你不想在任何情况下显示焦点矩形您可以将FocusVisualStyle设置为null。

 < MyControl FocusVisualStyle ={x:Null}/> 


I have a WPF UserControl with Focusable="True". It's the only focusable control in the window.

Whenever the user presses Tab or Alt (and especially when they Alt+Tab to another application), my UserControl acquires a dotted-line border, aka focus rectangle. The focus rectangle then stays there until the window is closed.

How can I prevent my UserControl from ever displaying this focus rectangle?

Edit

It turns out the focus rectangle wasn't actually being displayed by my UserControl. My Focusable UserControl contained another UserControl that, in turn, contained an ItemsControl, and the ItemsControl is what was showing the focus rectangle.

When I added FocusVisualStyle="{x:Null}" to the ItemsControl, the focus rectangle went away.

解决方案

If you want to not display the focus rectangle in any case you could set the FocusVisualStyle to null.

<MyControl FocusVisualStyle="{x:Null}" />

这篇关于删除UserControl上的焦点矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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