ValidationSummary simply takes whatever control (UIElement) is in "Target" property and hooks up to its
BindingValidationError event. If you don't set a target in your XAML or code-behind and you leave it null, then ValidationSummary just calls VisualTreeHelper.GetParent() on itself and hooks into its parent control. Unfortunately, if you want
the errors to be automatically added for you, that's the approach you have to use (letting errors bubble up through the BindingValidationError event).
In your case, if you want to manually use the Validator class to validate your object, you'll need to manually add the resulting error messages to the ValidationSummary. To do that, just add ValidationSummaryItems to the ValidationSummary.Errors
collection.
sapientcoder
Member
492 Points
99 Posts
Re: How to manually validate an object and have the results automatically added to a ValidationSu...
Jul 21, 2009 03:20 PM | LINK
ValidationSummary simply takes whatever control (UIElement) is in "Target" property and hooks up to its BindingValidationError event. If you don't set a target in your XAML or code-behind and you leave it null, then ValidationSummary just calls VisualTreeHelper.GetParent() on itself and hooks into its parent control. Unfortunately, if you want the errors to be automatically added for you, that's the approach you have to use (letting errors bubble up through the BindingValidationError event).
In your case, if you want to manually use the Validator class to validate your object, you'll need to manually add the resulting error messages to the ValidationSummary. To do that, just add ValidationSummaryItems to the ValidationSummary.Errors collection.
Blog: doseofdotnet.wordpress.com