O'Reilly logo

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF by Muhammad Shujaat Siddiqi, Ryan Vice

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validation in MVVM-based applications

As mentioned in the introduction to this chapter, we have a lot of validation options to choose from in XAML-based technologies. Let's now take a look at the options that are best suited for use in MVVM applications.

Validation rules

This is the simplest and most commonly used validation technique. A WPF binding can be associated with a number of custom validation rules, each subclassed from ValidationRule. There are only two validation rules provided as part of the library: DataErrorValidationRule and ExceptionValidationRule.

Using validation rules

We can define additional custom validation rules by inheriting from ValidationRule. We can add them to the ValidationRules collection for a binding, as follows: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required