如何在WPF中更改应用程序文化? [英] How to change Application Culture in wpf?

查看:115
本文介绍了如何在WPF中更改应用程序文化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码。

double value = double.Parse(Utility.GetParamValueOrDefault(omRecord.paramList[i].value, "0"),CultureInfo.CurrentCulture);

这是我得到
的错误 FormatException:
输入字符串的格式不正确

我已经阅读了StackOverFlow的一些线程,说我需要将以下代码添加到WPF应用程序的main()中

i have read some threads of StackOverFlow saying i need to add into main() of my WPF application the following code.

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

我仍然遇到相同的错误,而我的CurrentCulture仍然不在美国。

i still get the same error and my CurrentCulture is still not en-US.

推荐答案

尝试一下

CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

这篇关于如何在WPF中更改应用程序文化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆