What is the correct way to implement feature of runtime localization change in MVVM Light WPF app? I am using Resource based localization (.resx files) and I want to have option of changing locale in almost any moment.
I though at first about doing global property in App.xaml.cs
with LocalizationChanged
event wired up in every View, but this violate at least two rules of MVVM: not having code in code-behind and coupling View class together, because they will be depended on App class (it will be harder to unit test them)
Another idea was to create global interface ILocalizableModel
which will be implemented by LocalizableModel
class (injected at runtime via mvvm light magic), which then provide interface to register LocalizationChanged
event and way to set new localization (and maybe some other functionality like enumerate available localizations). The event will fire in ViewModel classes and request them to update all properties. This has another problem: some View data (like lists) cannot be updated without recreating them. And handling strongly View-specific code in ViewModel also seems like a bit twisted idea.
Another idea is to use Observator pattern or auto property wired in Model.
But what is the "correct", MVVM way to do so?