O'Reilly logo

Mastering Windows Presentation Foundation by Sheridan Yuen

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

Incorporating multiple validation techniques

Now that we've had a good look at the two validation interfaces, the data annotation attributes and the ability to validate with different levels, let's take a look at how we can amalgamate these different techniques together.

Let's create a BaseNotifyValidationModel class by copying what we have in our previous implementation, to incorporate these new additions. First, we need to add some extra using directives to the ones used in the previous implementation:

using System.Collections.ObjectModel; 
using System.Collections.Specialized; 
using System.ComponentModel.DataAnnotations; 
using CompanyName.ApplicationName.DataModels.Enums; 

Next, we need to add our validationLevel and errors fields:

private ValidationLevel ...

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