I have a multi language application that allow user to switch language using dropdown menu. It works fine, but it is too slow when switching the language because I need to re-navigate to my current frame. This is because I need to reload my products (which takes a bit of time).
Here is my code:
var culture = new System.Globalization.CultureInfo(sLang);
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
Frame.Navigate(Frame.CurrentSourcePageType); //I want to avoid this as calling this will re-initialize my page - which in turn re-load my products
My question is, is there a way to force all component with x:Uid to reload from resource file (eg. Strings/en-US/Resources.resw) without calling Frame.Navigate()?
In WinForm, I can do something like:
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(MainForm));
foreach (Control ctl in this.Controls)
{
rm.ApplyResources(ctl, ctl.Name);
}
Is there any equivalent in UWP? Or is there any better way to tackle my problem?
Thanks
I used this pattern from the documentation which uses this sample to notify a change in my data. If im not wrong, you want to notify the xaml element's content(e.g. Text) when it changes. Then you need to use binding.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With