开发者

How can I force a textBox in wpf to call OnLostFocus in a unit test?

I have a custom comp开发者_开发技巧onent created in WPF using C#, where I have some validation that are checked when the textbox OnLostFocus is called (it is only when the user leaves the textbox I can do the validation, since only then do I have the complete input string to validate).

How can I trigger the OnLostFocus on the textBox from the unit test?

Thanks


You're not really clear how you're doing the testing but two things spring to mind.

  • If you actually want the text box to lose focus then set focus to another control by calling someOtherControl.Focus()
  • If you just want to test the OnLostFocus processing then call the method directly.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜