Silverlight / WPF - date comparison in wpf - Asked By krutik sheth on 13-Apr-10 12:23 PM

Hello all,

I have two dates, (Activation date and Expiry date) on my WPF form.
Now validation I have to check is that Activation Date should be less then Expiry date.

Now How can I build a validator to achive this task?

What I have done on my form is I have created Error Template for controls that i use in app.
I can check this validation by code also but in this case my error template is not shown.

Michael Detras replied to krutik sheth on 13-Apr-10 09:11 PM
Here's a useful link: http://davidhayden.com/blog/dave/archive/2007/03/02/PropertyComparisonValidatorValidationApplicationBlock.aspx

This uses the Enterprise Library Validation Application Block. I recommend you use a validation framework. There are others aside from Enterprise Library. Here's an article I wrote regarding WPF input validation using the Enterprise Library. Hope this helps.

http://eggheadcafe.com/tutorials/aspnet/f726cd7d-cfcc-43c3-85d8-2afc75e7a08a/wpf-input-validation-with.aspx