Responsive Override Metadata h2>
Some form of reloading is inevitable because changing the Language control does not make it an update to its text.
However, there is a way to override metadata that allows you to set once and new controls automatically use the current culture:
FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( System.Windows.Markup.XmlLanguage.Empty, default(PropertyChangedCallback), _CoerceCurrentXmlLang));
where is CoerceValueCallback -
private static object _CoerceCurrentXmlLang(DependencyObject d, object baseValue) { var lang = baseValue as System.Windows.Markup.XmlLanguage; var culture = System.Globalization.CultureInfo.CurrentUICulture; return lang != null && lang.IetfLanguageTag.Equals(culture.Name, StringComparison.InvariantCultureIgnoreCase) ? lang : System.Windows.Markup.XmlLanguage.GetLanguage(culture.Name); }
This alone is not enough, because the newly created controls will get the default value of System.Windows.Markup.XmlLanguage.Empty without coercion. However, if you then set xml:lang="" to the XAML window, this will be forced, and then each new control will see that it inherits the value from its parent and force it. As a result, new controls added to this window will use the current language.
PS As with many things in WPF, it would be much simpler if they did not try to keep things internal . DefaultValueFactory would be a much more elegant way to do this.
reloading
The most extreme, but, therefore, reliable way to reboot is to simply create a new main window and abandon the old one.
Almost as extreme, but not quite so that the language setting was changed only in a very simple panel of the main window with a very small load, and that very little was completely tied to the presentation model, which supports forcing the changed notification property for everything.
The existing answers to this question have other suggestions.