I'm doing a small research on localisation methods in WPF. I heard about the idea with markup extension:
<Label Content="{local:Translate {-- label ID here --}}" />
I like this solution very much: it's extremely easy to implement and seems to be nicely flexible. I've got one concern, however. Let's suppose, that user changes the locale in the runtime. How to ensure, that localized properties will be reevaluated to match new language?
You would need to call DependencyObject.InvalidateProperty. Keep in mind that if you were binding to an object implementing
INotifyPropertyChanged
they would reevaluate by way of the underlying data changing.DependencyObject.InvalidateProperty
can be called on a givenDependencyProperty
such asLabel.Content
.This would have to be done for the varying properties that need re-evaluation. There is an in depth article on MSDN around localization within WPF for varying alternatives as well that should be investigated.