Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching language at runtime in Windows Store Apps

In my Windows Store App application I have an option to switch the language by setting ApplicationLanguages.PrimaryLanguageOverride to the locale I want to use.

I have different resource files for each language and it works fine for reloaded pages and resources loaded from code-behind.

But now there is a problem with cached pages (NavigationCacheMode = Enabled): those pages have text localized directly in xaml using uids, and those don't get reloaded when the language changes.

Any idea how to reload those resource tagged as uids without restarting the app?

like image 997
Julien Avatar asked Jan 29 '26 05:01

Julien


1 Answers

For me worked deleting the Navigationcache like that after switching the primarylanguageoverride:

    var Frame = Window.Current.Content as Frame;
    Frame.CacheSize = 0;
    Frame.Navigate(Frame.CurrentSourcePageType);
    Frame.CacheSize = 10;
    Frame.GoBack();

After that the Current Page is reloaded in the correct language.

like image 174
Jmie Avatar answered Feb 02 '26 00:02

Jmie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!