Silverlight ValidatesOnException default message localization

风流意气都作罢 提交于 2019-12-04 05:26:31
Mamta D

Perhaps you aren't changing the culture at the outset.

I suggest that you try the approach given in the first answer in this link:

Change culture of Silverlight application

One possible approach is to change the type of the property to string, even though you're storing a decimal value behind it. The getter would call ToString on the decimal value stored, and the setter would do the conversion back from string to decimal using Decimal.Parse or similar. This approach does mean you have to do the type conversion yourself, but it does at least give you a bit more control.

Your setter can throw exceptions to indicate validation errors. Alternatively, you can use one of the interfaces IDataErrorInfo and INotifyDataErrorInfo to show the validation error. This page has an example of using IDataErrorInfo, and this one has an example using INotifyDataErrorInfo.

You can use custom implementation of ValidationRule and add to the Binding.ValidationRules collection. You'll have to clear the collection before (I am not sure how to do it XAML) and add this rule (how to do it is described in one of the MSDN page).

This class has Validate method, where you can perform your validation and return the error message you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!