question

Ivanich avatar image
0 Votes"
Ivanich asked ·

x:Uid cache

Hi,

Is there some way to disable or reliably refresh localized string resources cache in UWP app?

I am working on the wizard where user should select preferred language on the welcome page, which is always in English, and then navigate to next pages where I use x:Uid to localize <TextBlock /> and other controls. So, before navigation to localized pages I set current culture this way:

 CultureInfo.CurrentCulture = culture; // this changes CurrentUICulture too
                
 ResourceContext.GetForCurrentView().Reset();

It works good on my testing devices, but some people report that when they navigate back to the first page and change language second time, text labels keeps showing in the language selected first time. I have not enabled NavigationCacheMode, so pages are recreated every time when user navigates to them, and only one reason for such behavior that I can imagine is some caching at the resource management system level. Maybe it is not enough just call Reset() on ResourceContext or there is some known bug related to resources caching?

windows-uwp
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, I want to confirm that you have created multiple resw resources but cannot switch dynamically, or do you want to directly modify the content of the resw resource file?

0 Votes 0 ·
Ivanich avatar image Ivanich RichardZhang-MSFT ·

I use multiple .resw files, of course.

0 Votes 0 ·
RichardZhang-MSFT avatar image
0 Votes"
RichardZhang-MSFT answered ·

Hello,​

Welcome to our Microsoft Q&A platform!

You can try calling the following method to clear the cache:

 Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
 Windows.ApplicationModel.Resources.Core.ResourceManager.Current.DefaultContext.Reset();

After clearing the cache, the page needs to be reloaded.

Thanks.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MR-8558 avatar image
0 Votes"
MR-8558 answered ·

User resources

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.