如何在Windows Phone应用程序的代码中设置UI语言?

时间:2013-09-30 15:57:41

标签: windows-phone-7 windows-phone-8 localization windows-phone

假设我的应用程序不支持文化es-MX,所以当这是手机上的当前设置时,我想将文化设置为es-ES。这可以在Windows Phone中完成吗?如果可以的话怎么办?

1 个答案:

答案 0 :(得分:4)

这绝对是可能的! 有关文化及其标识符,请参阅this list

例如,在App.xaml.cs构造函数中,您可以访问Thread.CurrentThread.CurrentCulture来确定应用程序运行的实际文化。现在,如果您想强制UI使用其他文化,您可以通过设置CurrentUICulture。例如:

if (Thread.CurrentThread.CurrentCulture.Name.Equals("es-MX"))
{
    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-ES");
}
相关问题