I have TextBox which should only contain a valid integer. It’s validated using a custom ValidationRule. The problem I am experiencing is that when the TextBox.Text is invalid, say “3a”, and I type another “a”, then the TextBox’s attached property Validation.HasError changes from TRUE -> FALSE -> TRUE. My software reacts whenever the Validation.HasError is FALSE, but the TextBox.Text is “3a” at that point in time which is not desirable.
Here is how I see things: The TextBox.Text="3a" and Validation.HasError=TRUE. Now I type an additional “a” and the following happens. First the Validation process removes the existing ValidationError and raises a Validation.Error event with ValidationErrorEventArgs.Action=”Removed”. Now the Validation.HasError=FALSE. Straight afterwards the Validation process adds a new ValidationError and raises a Validation.Error event with ValidationErrorEventArgs.Action=”Added”. Now the Validation.HasError=TRUE again.
All I can do is react to Validation.Error events and then inspect the source object’s Validation.HasError attached property to see if it is true or false. Unfortunately the Validation.HasError returns false when the TextBox.Text=”3a” which is clearly not a valid integer.
Any ideas would be very helpful. Thanks :)