I don't generally have much time for blogging but this took me so long to find the answer I thought this might be helpful. The problem is more of an irritation than anything. When validating using a data context you need to throw an exception in the setter of the property you bind against. If in debug mode Visual Studio breaks on the exception that the UI uses to show the Invalid state of the control you are validating. This can be avoided by using CTRL+F5 or pressing F5 after the application breaks. However, if you are like most developers you write and test code in debug mode so you want the ValidationException to just cause the validation framework to do it's thing without breaking.
Here's how:
If you are using ValidationException which you should be, you will have a reference to System.ComponentModel.DataAnnotations
Go to Debug - Exceptions - Common Language Runtime Exceptions
Click Add... Then add System.ComponentModel.DataAnnotations.ValidationException and make sure it is unchecked.
And That's All Folks!
Currently rated 5.0 by 1 people
- Currently 5/5 Stars.
- 1
- 2
- 3
- 4
- 5