Change App language at RunTime on-the-fly

后端 未结 3 1554
鱼传尺愫
鱼传尺愫 2020-12-19 02:48

I\'m currently developing a metro app in which the user can change current language at runtime and all the custom controls that are loaded must update their text regarding t

3条回答
  •  渐次进展
    2020-12-19 03:32

    Use this:

    var NewLanguage = (string)((ComboBoxItem)e.AddedItems[0]).Tag;
    
    Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = NewLanguage;
    
    Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
    //Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
    
    Windows.ApplicationModel.Resources.Core.ResourceManager.Current.DefaultContext.Reset();
    

    and then reload your Page, using Navigate method:

    if (Frame != null)
        Frame.Navigate(typeof(MyPage));
    

提交回复
热议问题