Change Thread.CurrentThread.CurrentUICulture with Windows settings

74 Views Asked by At

I have the problem that

Thread.CurrentThread.CurrentUICulture is de-DE
Thread.CurrentThread.CurrentCulture is de-CH.

When I change the keyboard layout to de-CH Thread.CurrentThread.CurrentUICulture is not changed to de-CH. What have I to do that this value will be changed?

The problem is that I get in WPF the ',' decimal separator instead of '.'

2

There are 2 best solutions below

1
Aleksei Petrov On

Answering your question directly: keyboard layout is not UI Culture. CurrentUICulture is Windows language. Not sure about other Windows versions, but in Windows 11 it's Settings -> Time & Language -> Language & Region -> Windows display language:

Windows display language

But decimal separator in not defined by CurrentUICulture, but CurrentCulture, which is different. In Win11 it's Regional Format: Regional Format

In general, correct strategy of proper decimal separator (as a part of general application localization) is a big question and could be solved in many different ways based of your user preferences/business expectation and so on. Possible options could be:

  1. Just use current culture and believe that user will use separator of his culture
  2. Force user to use only '.' and specify CultureInfo.InvariantCulture while parsing
  3. Try to parse number with both separators

and others...

0
ora On

Under Windows 10 here the language Settings. Every setting is set to Deutsch(Schweiz) except the language recognition.

enter image description here

But I get this: enter image description here

I am using .NET 7