A ValidatioRule in a BindingExpression only triggers, when the target
side of the binding changes. If you want to set a validation error by
code you can use the following snippet.
Set the validation error
ValidationError validationError = new ValidationError(regexValidationRule, textBox.GetBindingExpression(TextBox.TextProperty)); validationError.ErrorContent = "This is not a valid e-mail address"; Validation.MarkInvalid( textBox.GetBindingExpression(TextBox.TextProperty), validationError);
No comments:
Post a Comment