views:

92

answers:

1

Hi,

I have a little problem with the current format of my negative currency number. Here's a screenshot resuming my situation.

  1. This is how I'm using the StringFormat in my binding. (BTW, I tried only {0:C})
  2. As expected
  3. The current settings of my computer for the negative currency number 4.
  4. The result when I'm running my application

alt text

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 the Thread.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 its CurrentNegativePattern was not the same as in the Thread.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 the Convert method of my converter.
A: 

Try changing the CurrentCulture to 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. 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 a CultureInfo.

Pieter
Unfortunately, it doesn't work.
esylvestre
That is because you have no way of specifying the specifics of the culture, and it uses the generic settings of the culture. I think the only way you can achieve this is using the `ConverterCulture` property of the binding, but I think this will be a pain to apply. This actually does take a `CultureInfo`, but it doesn't look easy to use.
Pieter
So what do you think avout the solution I'm currently using (see update in my main post -I'm talking about a Converter using the CurrentThread.CurrentCulture- )?
esylvestre
It does sound OK.
Pieter
Yeah, like you said, OK. But I still want the best ;)
esylvestre