2011-10-12 56 views

回答

2

您必须继承TextBox类,然后在所有代码中使用它。

然后,您可以将GotFocus事件处理程序放入该子类中,否则您必须将GotFocus事件处理程序添加到您的所有代码中。

public class MyTextBox : TextBox 
{ 
    protected override void OnGotFocus(RoutedEventArgs e) 
    { 
     // Add your code in here 
     base.OnGotFocus(e); 
    } 
} 

然后在你的XAML你必须:

<my:MyTextBox ..... /> 
+0

再次感谢:) – user278618

相关问题