[英]Negative currency number XAML
I have a little problem with the current format of my negative currency number. 我的负货币编号的当前格式有点问题。 Here's a screenshot resuming my situation.
这是一个截图,恢复了我的情况。
Why the result isn't -0,08 $ ? 为什么结果不是-0,08 $?
Any ideas of how I should proceed? 关于我应该如何进行的任何想法?
Thanks for your time. 谢谢你的时间。
UPDATE: 更新:
I tried to resolve the problem with a converter, here's the result : 我尝试用转换器解决问题,结果如下:
Thread.CurrentThread.CurrentUICulture
was not the same as the Thread.CurrentThread.CurrentCulture
, so I fixed it in my App.xaml.cs. Thread.CurrentThread.CurrentUICulture
与Thread.CurrentThread.CurrentCulture
,所以我在App.xaml.cs中修复了它。 Unfortunately, same result. Convert
method was okay, but its CurrentNegativePattern
was not the same as in the Thread.CurrentThread.CurrentCulture
. Convert
方法的参数中收到的文化是可以的,但它的CurrentNegativePattern
与Thread.CurrentThread.CurrentCulture
中的不一样。 That's probably the reason why I have this problem. return ((double)value).ToString("C2", Thread.CurrentThread.CurrentCulture);
return ((double)value).ToString("C2", Thread.CurrentThread.CurrentCulture);
in the Convert
method of my converter. Convert
方法中。 Try changing the CurrentCulture
to CurrentUICulture
: 尝试将
CurrentCulture
更改为CurrentUICulture
:
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag))
);
Please note though that this may not use your regional settings. 请注意,这可能不会使用您的区域设置。 The
CultureInfo
object does describe your regional settings, but what you're doing with the IetfLanguageTag
is extracting that to a specific culture. CultureInfo
对象确实描述了您的区域设置,但您对IetfLanguageTag
是将其提取到特定文化。 That culture does not have the adjustments you've made to your regional settings. 该文化没有您对区域设置所做的调整。
Alternatively, you can have a look at the ConvertCulture
option of the binding. 或者,您可以查看绑定的
ConvertCulture
选项。 This actually does take a CultureInfo
. 这确实需要一个
CultureInfo
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.