x:Uid cache

Ivanich 306 Reputation points
2020-02-24T18:31:50.747+00:00

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?

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Richard Zhang-MSFT 6,936 Reputation points
    2020-02-26T05:55:14.08+00:00

    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Mishu017 1 Reputation point
    2020-02-24T19:37:42.553+00:00

    User resources

    0 comments No comments