在运行时更改通用应用中的语言

时间:2015-04-22 09:55:01

标签: windows-phone-8.1 windows-8.1 win-universal-app

我想在运行时更改我的通用应用程序中的语言 - 而不是在重新启动应用程序时, 我试过这段代码:

{{1}}

语言不会改变正确;它有时会改变,有时也不会改变。 我不知道是什么原因 - 这个问题出现在Windows 8.1和Windows Phone 8.1中。

1 个答案:

答案 0 :(得分:1)

尝试:

var culture = new CultureInfo("en-US");
                    Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
                    CultureInfo.DefaultThreadCurrentCulture = culture;
                    CultureInfo.DefaultThreadCurrentUICulture = culture;
                    (Window.Current.Content as Frame).FlowDirection = Windows.UI.Xaml.FlowDirection.LeftToRight;
                    var loader = new Windows.ApplicationModel.Resources.ResourceLoader();

另外,将ar-EG的流向设置为:

(Window.Current.Content as Frame).FlowDirection = Windows.UI.Xaml.FlowDirection.RighttoLeft;

对于我们:

(Window.Current.Content as Frame).FlowDirection = Windows.UI.Xaml.FlowDirection.LeftToRight;