views:

350

answers:

2

Hi

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

+4  A: 

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!

Donut
The problem is, applications seems to crash in a way that even after the exception is ignored (either with F5 or by doing what your techniques described), the entire UI goes blank and loses all controls. That seems like a crash to me... I'm not doing anything weird, I just throw an exception in the property setter and that's it. Can't figure this out...
VexXtreme
+1  A: 

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.

VexXtreme