UserControl LostFocus

时间:2012-12-03 12:57:28

标签: lostfocus

我有一个包含TextBox的UserControl。 我想注册UserControl的LostFocus,这意味着如果用户按下我的UserControl的 out ,则应该调用该事件。

但是我在UserControl中为每个TextBox LoseFocus获取此事件。

为什么?

主窗口:

<StackPanel>
  <TextBox Width="100" Height="40" Text="A"/>
  <WpfApplication2:UserControl1/>
</StackPanel>

用户控件:

<StackPanel>
   <TextBox Width="100" Height="40" Text="B"/>
   <TextBox Width="100" Height="40" Text="C"/>
</StackPanel>

在用户控件的代码中:

LostFocus + = UserControl1_LostFocus;

现在,当您点击任何一个TextBox时,即使在文本框中,也会调用UserControl。 我只注册了UserControl LostFocus,而不是TextBoxs。

0 个答案:

没有答案
相关问题