I have the code below to change the language of my app, but it is proving to be unreliable. My app is made up of a MainPage and a bunch of UserControls, loaded on when the page is created. When I change the language via a button press on the page it is 50/50 as to whether the language changes. Usually the MainPage language changes quite reliably, but the UserControls are very unreliable. Is there anything I can do to improve the reliability?
The method below also causes an unpleasant flicker when the page is reloaded.
If I restart the app after changing the language then everything looks as it should.
string lang = newLanguage;
ApplicationLanguages.PrimaryLanguageOverride = lang;
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
Frame.Navigate(Frame.CurrentSourcePageType, null);
The document has explained "When you set the PrimaryLanguageOverride, this is immediately reflected in the ApplicationLanguages.Languages property. However, this change may not take effect immediately on resources loaded in the app UI. To make sure the app responds to such changes, you can listen to the QualifierValues property on a default resource context and take whatever actions may be needed to reload resources. Those requirements may vary depending on the UI framework used by the app, and it may be necessary to restart the app."
Please read ApplicationLanguages.PrimaryLanguageOverride for more details.