Deborah's Developer MindScape

         Tips and Techniques for Web and .NET developers.

May 1, 2011

Silverlight MVVM, RIA, and Validation

Filed under: ASP.NET RIA Services,C#,Silverlight,VB.NET @ 5:43 pm

One of the biggest challenges of implementing validation in Silverlight is finding the appropriate technique based on your architecture and goals. There are lots of choices and lots of examples, but not all examples work in all scenarios. Plus many examples demonstrate techniques that are no longer necessary or valid in the current version of Silverlight or when using WCF RIA services.

Below are a set of posts on techniques for performing validation with Silverlight 4.0 using MVVM, WCF RIA Services, and custom business objects.

A few things to keep in mind if you are using Silverlight and WCF RIA Services:

  1. In most cases, the code should not need to throw exceptions for validation errors.
  2. The latest version of Silverlight/RIA provides automatic validation and a built-in validation error dictionary, so you do not have to write any code to build or populate validation errors.

The last point is an important one because there are videos and posts that go through the pages and pages of code required to manage your own validation and validation error dictionary. While this code is necessary and useful if you are using WCF directly, it is not necessary if you are using WCF RIA Services.

Here are the links:

Click on a link to navigate to the desired post.



  1.   Olivier — May 1, 2011 @ 10:28 pm    Reply

    One big problem with validations is how to validate “last” field the user is always within while she click the “ok” button of the dialog.. Depending on scenarios, the “last” field does not lost focus and then is not validated.
    Playing a bit with all this validation stuff and trying to implement it in real application let me see there are some problems of this kind..
    Have you some advice to give ?
    thanks in advanve (for the posts, and perhaps for your answer 🙂 ).

  2.   DeborahK — May 2, 2011 @ 12:05 am    Reply

    Hi Oliver –
    Using the sample application along with the changes to support single field validation, you should find that the data is also automatically validated before the submit. So the “last” field issue should not be a problem.
    Try the sample code, adding in validation attributes as defined in this link:
    And see if it is still a problem for you.

    Hope this helps.

  3.   SUZIE — July 9, 2011 @ 5:06 am    Reply

    Bravo very beautiful blog ! Thank’s

  4.   suzie — July 9, 2011 @ 5:13 am    Reply

    Bravo very beautiful blog ! Thank’s

  5.   Ashwin — November 16, 2011 @ 7:53 pm    Reply

    Is there any way to also addin async validation in ViewModel? i.e. to check if the entered email address already exists in the database?

  6.   John — December 5, 2012 @ 3:49 pm    Reply

    Is VB code coming soon…?

RSS feed for comments on this post. TrackBack URI

Leave a comment

© 2023 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs