开发者

wpf update validation errors when changed culture

I have an application that supports multilanguage.

When application language is changed, I can refresh the labels text with access each of the label and change content.

However, I can't change the validation errors (IDataErrorInfo) text with the related language.

开发者_如何转开发Is there a way to update/refresh the errors text?

Not: I try to get binding expression and force UpdateTarget/UpdateSource method, it did not work.


We have a wrapper class that wraps IDataErrorInfo. With this class, it is possible to SetFieldError(string fieldName, string error) or SetBusinessRuleError(string error).

This way, you can make your errors multilanguage:

SetFieldError("myField", Resources.MyErrorDescription);

When you move the string to a resource file, you only have to set the current culture, and make sure all translations of the resource files of that culture are available.

Then, for the INotifyPropertyChanged for the field (in this case "myField") so the WPF engine knows that the property should be updated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜