在 App.xaml.cs 我有:
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)));
在我的 MainWindow.xaml.cs 我有:
NumberFormatInfo nfi = System.Threading.Thread.CurrentThread
.CurrentCulture.NumberFormat;
nfi.CurrencySymbol = "USD";
nfi.CurrencyDecimalSeparator = ".";
nfi.CurrencyDecimalDigits = 0;
NumberFormatInfo nfi = System.Threading.Thread.CurrentThread
.CurrentUICulture.NumberFormat;
nfi.CurrencySymbol = "USD";
nfi.CurrencyDecimalSeparator = ".";
nfi.CurrencyDecimalDigits = 0;
现在在另一个将从 MainWindow 打开的窗口中,我写了以下内容:
<TextBox Text="{Binding Total, StringFormat=c}"
但结果是 1,200.00 美元,而不是我的预期:1,200 美元。这里有什么问题?