负货币号XAML
我的负货币数字的当前格式有一点问题。 这是恢复我的情况的屏幕截图。
- 这就是我在绑定中使用 StringFormat 的方式。 (顺便说一句,我只尝试了 {0:C})
- 如预期
- 我的计算机的当前设置为负货币数字 4.
- 运行应用程序时的结果
为什么结果不是 -0,08 $ ?
我应该如何进行有什么想法吗?
感谢您抽出时间。
更新:
我尝试使用转换器解决问题,结果如下:
- 我发现
Thread.CurrentThread.CurrentUICulture
与Thread不同。 CurrentThread.CurrentCulture
,所以我在 App.xaml.cs 中修复了它。不幸的是,同样的结果。 - 我尝试通过转换器显示我的值,看看是否可以调试问题。事实是,
Convert
方法的参数中收到的区域性没问题,但其CurrentNegativePattern
与Thread.CurrentThread.CurrentCulture< 中的不同。 /代码>。这可能就是我遇到这个问题的原因。目前,我将在以下方法的
Convert
中使用:return ((double)value).ToString("C2", Thread.CurrentThread.CurrentCulture);
我的转换器。
I have a little problem with the current format of my negative currency number.
Here's a screenshot resuming my situation.
- This is how I'm using the StringFormat in my binding. (BTW, I tried only {0:C})
- As expected
- The current settings of my computer for the negative currency number
4. - The result when I'm running my application
Why the result isn't -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 :
- I found that the
Thread.CurrentThread.CurrentUICulture
was not the same as theThread.CurrentThread.CurrentCulture
, so I fixed it in my App.xaml.cs. Unfortunately, same result. - I tried to display my values through a converter to see if I could debug the problem. The fact is that the culture received in the parameters of the
Convert
method was okay, but itsCurrentNegativePattern
was not the same as in theThread.CurrentThread.CurrentCulture
. That's probably the reason why I have this problem. for the moment, I'll use this :return ((double)value).ToString("C2", Thread.CurrentThread.CurrentCulture);
in theConvert
method of my converter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将
CurrentCulture
更改为CurrentUICulture
:请注意,这可能不会使用您的区域设置。
CultureInfo
对象确实描述了您的区域设置,但您使用IetfLanguageTag
所做的是将其提取到特定的区域性。该文化没有您对区域设置所做的调整。或者,您可以查看绑定的
ConvertCulture
选项。这实际上需要一个CultureInfo
。Try changing the
CurrentCulture
toCurrentUICulture
: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 theIetfLanguageTag
is extracting that to a specific culture. 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. This actually does take aCultureInfo
.看看这个
http://msdn.microsoft.com/en-us/库/ms745650.aspx
http://msdn.microsoft.com/ en-us/library/ms788718.aspx
Take a look at this
http://msdn.microsoft.com/en-us/library/ms745650.aspx
http://msdn.microsoft.com/en-us/library/ms788718.aspx