Quantcast
Viewing all articles
Browse latest Browse all 10

Data validation in WPF using ValidationRule

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 Image may be NSFW.
Clik here to view.
:-(

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


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>