#763 – The Difference Between CurrentCulture and CurrentUICulture

In a WPF application, you have access to two properties that give you information about the user’s culture and language.  They are both properties of a Thread object, which you can access via Thread.CurrentThread.

  • CurrentCulture – Tells you the user’s current locale, as set in the Region applet.  I.e.: Where is the user located?
  • CurrentUICulture – Tells you the native language of the version of Windows that is installed.  I.e.: What language does the user speak?

The user can change CurrentCulture using the Region applet.  It’s used to determine formatting for numeric and date/time strings.

763-001

The user normally can’t change CurrentUICulture without re-installing Windows.  It’s used to know what language to use when displaying text in your application.  (I.e. Which resource files to load).

            CultureInfo ci = Thread.CurrentThread.CurrentCulture;
            lblCurrentCulture.Content = string.Format("CurrentCulture = {0} - {1}", ci.Name, ci.DisplayName);

            ci = Thread.CurrentThread.CurrentUICulture;
            lblCurrentUICulture.Content = string.Format("CurrentUICulture = {0} - {1}", ci.Name, ci.DisplayName);

For example, someone in England might see:
763-002

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

5 Responses to #763 – The Difference Between CurrentCulture and CurrentUICulture

  1. It is worth noting that WPF uses its own “culture” for bindings that is not the same as any of these cultures, but will default to the US culture. So, if you bind to a DateTime in a TextBox, you will get the US date format. You can change this culture by setting the FrameworkElement.LanguageProperty element. It is inherited, so if you set it at the GUI root element, it will affect all of you application.

  2. Pingback: #764 – Current Culture Is Used When Converting Data to A String | 2,000 Things You Should Know About WPF

  3. Pingback: Weekly Digest 3 | chodounsky

Leave a comment