Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Validation Manually Adding Errors into Validation.Errors Collection

Tags:

validation

wpf

Is there any way to manually/dynamically add errors to the Validation.Errors collection?

like image 904
john doe Avatar asked Feb 01 '10 01:02

john doe


1 Answers

from http://www.wpftutorial.net/ValidationErrorByCode.html

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);
like image 120
jrwren Avatar answered Oct 17 '22 09:10

jrwren