问题描述
我有一个应用程序,它是基于对印度和我设置文化为:
Thread.CurrentThread.CurrentUICulture =新的CultureInfo(EN-IN);
以上code被设置窗口前 - InitializeComponent方法被称为
不过这是显示为$在CURRENCYSYMBOL所有的文本框。
如果我绑定文本框如下,它显示卢比。作为CURRENCYSYMBOL:
文本={结合工资,模式=双向,的StringFormat = C,ConvertCulture = EN-IN}。
我想你会需要增加以下内容。
Thread.CurrentThread.CurrentCulture =新的CultureInfo(EN-IN);
Thread.CurrentThread.CurrentUICulture =新的CultureInfo(EN-IN);
FrameworkElement.LanguageProperty.OverrideMetadata(typeof运算(FrameworkElement的),新FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
在这里阅读更多:
http://www.west-wind.com/weblog/posts/2009/Jun/14/WPF-Bindings-and-CurrentCulture-Formatting
只是为了给你举个例子,我这是怎么初始化文化在我的程序,根据用户的设置,但你可以简单地取代 UserSettings.DefaultCulture
和 UserSettings.Default.UICultrue
与你想要的文化。
私有静态无效InitializeCultures()
{
如果(!String.IsNullOrEmpty(UserSettings.Default.Culture))
{
Thread.CurrentThread.CurrentCulture =新的CultureInfo(UserSettings.Default.Culture);
}
如果(!String.IsNullOrEmpty(UserSettings.Default.UICulture))
{
Thread.CurrentThread.CurrentUICulture =新的CultureInfo(UserSettings.Default.UICulture);
} FrameworkElement.LanguageProperty.OverrideMetadata(typeof运算(FrameworkElement的),新FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
}
I have an App, which is based for India, and I'm setting Culture as:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-IN");
The above code is being set before the Window - InitializeComponent method is called.
Still this is showing $ as CurrencySymbol in all the TextBox.
If I bind the TextBox as following, it shows 'Rs.' as CurrencySymbol:
Text="{Binding Salary,Mode=TwoWay,StringFormat=C,ConvertCulture=en-IN}".
I think you will need to add the following.
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-IN");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-IN");
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
Read more here:
http://www.west-wind.com/weblog/posts/2009/Jun/14/WPF-Bindings-and-CurrentCulture-Formatting
Just to give you an example, this is how I initialize the Culture in my program, based on the user setting, but you can simply replace UserSettings.DefaultCulture
and UserSettings.Default.UICultrue
with your wanted Culture.
private static void InitializeCultures()
{
if (!String.IsNullOrEmpty(UserSettings.Default.Culture))
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(UserSettings.Default.Culture);
}
if (!String.IsNullOrEmpty(UserSettings.Default.UICulture))
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(UserSettings.Default.UICulture);
}
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
}
这篇关于设置文化(EN-IN)在全球范围内的WPF应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!