1

I'm using this line to set the data binding localization:

FrameworkElement.LanguageProperty.OverrideMetadata(
    typeof(FrameworkElement),
    new FrameworkPropertyMetadata(
            XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

but I noticed that if I customize the language format in the control panel, for example by specifying another decimal separator, that change is not considered: the culture created is always the default.
Is there a way to solve this problem?
Thank you.

Maurizio Reginelli
  • 3,152
  • 2
  • 27
  • 41

3 Answers3

0

You will have to set a ConverterCulture in the Binding.

First, add the namespace xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib"

and then use

<TextBlock Text="{Binding Path=MyPath, ConverterCulture={x:Static gl:CultureInfo.CurrentCulture}}"/>

Found here: https://stackoverflow.com/a/6423124/785529

Community
  • 1
  • 1
Dani
  • 2,602
  • 2
  • 23
  • 27
0

Just a guess,

for this we may need to redo the metatdata overriding in a window message handler for two specific windows messages

Hex Dec Symbol

0050 80 WM_INPUTLANGCHANGEREQUEST

0051 81 WM_INPUTLANGCHANGE

See this code for handling windows messages in WPF

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6b97a6de-0480-4339-8ed0-cb7cdb27bd83/

Let me know if this helps.

WPF-it
  • 19,625
  • 8
  • 55
  • 71
  • If I am correct, these messages signal the application when a language change occurs. I need reading the informations from the control panel during the application startup, so I think that these messages can't help. Tell me if I'm wrong. Thank you again. – Maurizio Reginelli Sep 12 '11 at 10:07
  • But when you make these changes and say "Apply", only then you would want the changes to take effect isnt it? That is when we will receive the INPUTLANGCHANGE. – WPF-it Sep 12 '11 at 10:34
  • I'm sorry, there was a misunderstanding. I need to know the customizations made on global settings during my application startup and not when someone changes them. – Maurizio Reginelli Sep 12 '11 at 11:49
0

You should use the CultureInfo.CurrentUICulture.

sloth
  • 99,095
  • 21
  • 171
  • 219
  • I can use it but the problem still remains, because the property IetfLanguageTag contains only the language code and not the informations saved in the control panel. – Maurizio Reginelli Sep 12 '11 at 10:02
  • Did you have the same effect while changing the culture of the current thread? –  Sep 12 '11 at 15:09