How to add Validation?

Jan 8, 2013 at 2:52 PM

I have a Silverlight MVVM App.

I load data via a WCF Service and return the models via the service, therefore I placed the model files in the Web project. (is this correct)

How do I add validation such as the [Required] attribute and force the UI to show the errors?

 

Thank you, Raz

Feb 25, 2013 at 2:09 AM
If you are calling a WCF service, it's good practice to place your model classes in a separate assembly that is shared between client and service. Be sure to reference the common assembly from the client before you add a service reference to it. That way, it will use the references model classes instead of generating them as part of the service reference. The validation attributes work as documented.

All that said, if you are using Silverlight and performing validation, I highly recommend using RIA Services, because one of the things it offers is built-in validation. If you are interested, I have a webinar and blog post on this.

Cheers,
Tony
Feb 25, 2013 at 3:29 AM
Thank you! I ended up figuring out the problem! I used something similar to your solution. Thank you very much for SimpleMvvm though, it is a life saver!

Raz

On Feb 24, 2013, at 8:10 PM, "tonysneed" <notifications@codeplex.com> wrote:

From: tonysneed

If you are calling a WCF service, it's good practice to place your model classes in a separate assembly that is shared between client and service. Be sure to reference the common assembly from the client before you add a service reference to it. That way, it will use the references model classes instead of generating them as part of the service reference. The validation attributes work as documented.

All that said, if you are using Silverlight and performing validation, I highly recommend using RIA Services, because one of the things it offers is built-in validation. If you are interested, I have a webinar and blog post on this.

Cheers,
Tony