I have some validation code that uses masking and the PreviewTextInput and PreviewKeyDown events on a textbox. When I change the value in the textbox manually the validation works perfectly. When I set the values programatically the valdation doesn't start until I click in the box and delete a character and re-add it, manually firing one or both of the above events.
Is there a way to fire either of those events manually so that the validation will work?
I've tried stuff like:
this.TextBox.RaiseEvent(this.TextBox.PreviewTextInput);
But nothing seems to work. I can't get the types to match either. Any ideas are welcome.
The masking-based validation code I'm using can be seen here: How to define TextBox input restrictions?
You can use the following code to fake text input to a TextBox.