本文介绍了文本框引发LostFocus不火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有LostFocus事件的一个问题它不火的时候,我点击background.I阅读焦点逻辑和键盘焦点一些东西,但我无法找到一种方法,当从控件获得焦点,一个像文本框有只是其中之一。
XAML:
<电网HEIGHT =500WIDTH =500>
<文本框高度=23WIDTH =120保证金=12,12,0,0NAME =textBox1的引发LostFocus =textBox1_LostFocus/>
< /网格和GT;
C#:
私人无效textBox1_LostFocus(对象发件人,RoutedEventArgs E)
{
}
解决方案
您必须使用以下隧道事件:PreviewLostKeyboardFocus你的文本框
I have a problem with LostFocus event it does not fire when I click on the background.I read some stuff about focus logic and keyboard focus but I could not find a way to get the focus from a control a like textbox when there is only one of them
XAML:
<Grid Height="500" Width="500">
<TextBox Height="23" Width="120" Margin="12,12,0,0" Name="textBox1" LostFocus="textBox1_LostFocus" />
</Grid>
C#:
private void textBox1_LostFocus(object sender, RoutedEventArgs e)
{
}
解决方案
You must use the following tunnelling event : PreviewLostKeyboardFocus on your textbox
这篇关于文本框引发LostFocus不火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!