[英]Silverlight Textbox_LostFocus event not firing on Button_Click
I have one textbox and a Save Button in my silverlight. 我的Silverlight中有一个文本框和一个“保存”按钮。 The validations for the textbox are in its lostFocus event.
文本框的验证位于其lostFocus事件中。 But if I enter something in the textbox and directly press the save button, the validation is not working.
但是,如果我在文本框中输入内容并直接按保存按钮,则验证将无法进行。 In other words, the lostfocus event is not raising in the button_click event.
换句话说,lostfocus事件不会在button_click事件中引发。 How can I do this ?
我怎样才能做到这一点 ?
Call Focus()
on the button. 在按钮上调用
Focus()
。 For instance, if your button's name is "MyButton", you may use MyButton.Focus()
inside of it's click event. 例如,如果按钮的名称为“ MyButton”,则可以在其click事件中使用
MyButton.Focus()
。 I would also suggest that you simply call your textbox validation method inside of your button press event, then proceed only if all validations are successful. 我还建议您仅在按钮按下事件内调用文本框验证方法,然后仅在所有验证成功后再继续进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.