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.
精彩评论