1

In my app I have a custom validation rule for Textboxes in an ItemsControl, which works fine. However in my ViewModel I try to check if any of these Properties is invalid before executing a command with the

Validator.ValidateProperty

method. I'd expect that method to throw an exception when the validation fails (which it does on the UI as mentioned).

SearchParams.ForEach(x =>
 {
   var vc = new ValidationContext(x, null, null) { MemberName = "Value" };
   Validator.ValidateProperty(x.Value, vc);
 });

SearchParams is a List of SearchParamModel's, which has a property (of type object) Value.

In the XAML I have the UpdateSourceTrigger set to PropertyChanged, so even if the entered value fails the validation it get's bound to the Value property.

Why does it never throw an Exception even if the validation fails in the UI?

Shiffty
  • 2,086
  • 2
  • 26
  • 31

0 Answers0