WPF焦点丢失问题在同一控件中 [英] WPF Lost-Focus issue in same control

查看:94
本文介绍了WPF焦点丢失问题在同一控件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我专注于.net/wpf有一个小问题.我编写了一个包含TextBoxSearchButton的自定义用户控件.用户控件有一个丢失的焦点事件,如果焦点离开,该事件将验证文本框的内容.但是现在我有了问题,如果我单击搜索按钮,即使单击自定义用户控件中的按钮,也会触发用户控件的失去焦点事件. (该按钮还具有选项TabStop="False":

I have a small problem with focusing in .net/wpf. I have written a custom user control which contains a TextBox and a SearchButton. The user-control has a lost focus event, which validate the content of the textbox if the focus is leaving. But now i have the problem, if i click on my search button, the lost focus event of the user control gets fired, even if i click on the button in the custom user control. (The button additionally has the option TabStop="False":

问题是,如果我单击按钮,我不想触发该事件.

The problem is, that i don't want to fire the event, if i click on the button.

有人有主意吗?

谢谢!

推荐答案

设置

Focusable="False"

您的搜索按钮和文本框不会失去焦点,因为该按钮没有获得焦点.

of your search button and the TextBox will not lose the focus because the button doesn't get the focus.

这篇关于WPF焦点丢失问题在同一控件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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