Reputation:
I can't get dataform and it's controls to catch exceptions when validating.
Fir instance, I have:
<PasswordBox Password="{Binding Password,Mode=TwoWay,NotifyOnValidationError=true,ValidatesOnExceptions=true}" />
All required properties are set to true.
In the setter of my Password property I throw a ValidationException upon failed validation, but the data form doesn't catch it, it just causes the application to crash as if it were a normal exception.
Am I doing something wrong? Thanks
Upvotes: 4
Views: 1125
Reputation:
Ok, apparently Visual Studio was in some strange state where it was causing things to crash. After a restart, everything works perfectly. Validation works just as advertised.
Upvotes: 1
Reputation: 112825
Does it actually cause the application to crash, or does it just break into the debugger in Visual Studio?
If it simply breaks into the debugger, this is by design and nothing's actually broken. You can push F5 to continue, and your validation should work as expected.
In the long run though, this can get quite annoying. If you'd like, you can tell the debugger to ignore Silverlight Validation Exceptions as described here.
Another slightly different technique to avoid this issue is described here.
Hope this helps!
Upvotes: 3