Silverlight 3 Validation Exceptions

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 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: ekleeman
Posted on: 9/15/2009 at 2:33 PM
Tags: ,
Categories: Silverlight
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (727) | Post RSSRSS comment feed

Welcome

Welcome to the technical blogging section of ekleeman.com. This is where you will find pages describing how I developed the various controls and media content in the ekleeman.com pages. I will also describe how I implemented some third party tools like PageTurn and Slide.show2.

To see the various things I work on outside of my day job please visit ekleeman.com. If you see anything that interests you, you can come back here using the Blog link in the ekleeman.com site menu and search for the article describing how I coded the controls or implemented apps from other developers in the .NET or Silverlight communities. Please feel free to comment and make suggestions if you see me using techniques that are not "optimized" or if you just know of "an easier way".

-Cheers

Eric

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: ekleeman
Posted on: 1/28/2009 at 3:30 PM
Tags: , ,
Categories: .NET | Silverlight | VFP | WCF | WFP
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed