WPF Reflections

Mar 31 2008   11:01PM GMT

Data validation in WPF using ValidationRule

Mark Shurmer Profile: MarkWPF

As I mentioned in a previous post, you can specify validation by creating a Validation class (or classes).

You do this by deriving a new class from the ValidationRule class and overriding the Validate method.

Why would you do this, instead of implementing IDataErrorInfo?
Well, if you wanted to do validation across a number of objects, then this is the way to go.
It also provides a level of separation from your business objects, leaving them to deal with business data and the validation objects to deal with validation.
A downside is that it is not backwardly compatible with WinForms :-(

How do you tell your xaml to use it? By specifying it in the ValidationRules element of your binding – just like IDataErrorInfo.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: