问题描述
来自 App.cs 中的 OnLaunched
From OnLaunched in App.cs
这是有效的...
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "da-DK";
但这些都不是...
System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new System.Globalization.CultureInfo("da-DK");
System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("da-DK");
我没有反射它,但后者不应该一样好吗?
I haven't reflectored it but shouldn't the latter be just as good ?
我在这里遗漏了一点?
推荐答案
两者的区别在于System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("da-DK");代码>用于定义新创建线程的默认文化.这意味着已经在运行的线程不受它的影响.要更改已运行线程的区域性,您需要使用该运行线程内的
System.Globalization.CultureInfo.CurrentCulture
属性.
The difference between the two is that System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("da-DK");
is meant for defining the default culture of newly created threads. This means threads that are already running are not affected by it. To change the culture of a already runnning thread, you need to use the System.Globalization.CultureInfo.CurrentCulture
property inside that running thread.
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "da-DK";
范围更广,也会修改已经运行的线程.但它更多地用作应用程序中的语言选择",而不是作为 CultureInfo 的替代品(不仅用于语言,还用于转换、度量、格式等)
has a wider scope and will also modify the already running threads. But it's meant to be used more as a "language selection" within the application and not as a replacement for CultureInfo (which is not only used for language, but also for conversion, metrics, formatting etc.)
这篇关于如何在 Windows 8 应用程序中指定文化的根本变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!