Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customization of wrong format validation error messages in Silverlight & Wpf

Error messages associated with Validation attributes such as [Required] can be easily customized and localized either by providing directly the message string or a resource containing the message.

However, is it possible to customize the error message produced by Silverlight or Wpf when they are not able to convert the string in an input field into the type of the property the input field is bound to?

I have not found a clean way to do it! Also if you write your own converter and attach it to the binding, you are not able to produce a different message because Silverlight and Wpf only catch the exceptions produced by its standard converter. Exceptions thrown in user defined converters are not used to produce error messages but they just cause the application be aborted.

Does anyone knows a way to solve this issue?

like image 955
Francesco Abbruzzese Avatar asked Nov 05 '22 07:11

Francesco Abbruzzese


1 Answers

The problem of the converters you mentioned is reported only in the Wpf documentation. Exceptions thrown in the Silverlight IValueConverter.ConvertBack method should be transformed into a validation error

like image 95
Giovanni Avatar answered Nov 09 '22 06:11

Giovanni