You have already posted the same question before
here![
^]
And the answer lies there itself.
I can provide a brief answer here :
- Exception handling is used when you enter characters in the field which requires you to input only integer values. The error message it throws cannot be made custom. Also you cannot provide your own rule like age should be greater than 1 etc.
- ValidationRule is used to overcome the above two issues by creating a ValidationRule class to implement your own custom rule, also you can provide your own error message. The problem here is that for validating each control, you have to create a separate ValidationRule.
-IDataErrorInfo can be used to overcome the above issue. You just have to implement the IDataErrorInfo interface to the Class which holds the properties.
This is explained in my blog here :
http://tarundotnet.wordpress.com/2011/03/03/wpf-tutorial-how-to-use-idataerrorinfo-in-wpf/[
^]
Do have a look and i am sure you will be able to figure out yourself the solution for the problem.
Solution Updated :
Here are a few helpful links :
http://www.hardcodet.net/2009/01/combinding-wpf-validation-rules-and-idataerrorinfo-to-validate-conversion-errors[
^]
http://www.codegod.de/webappcodegod/wpf-idataerrorinfo-and-databinding-AID416.aspx[
^]
http://www.codeproject.com/KB/WPF/Validizor.aspx[
^]
Here is another simple implementation but lacks a thing which is covered and well explained at the first link or in my blog.
http://codeblitz.wordpress.com/2009/05/08/wpf-validation-made-easy-with-idataerrorinfo/[
^]