Setting the culture on WPF bindings

Situation

You work on WPF bindings, for example a binding to a DateTime object.

Problem

The DateTime object is displayed in en-US culture format.

Solution

Set the current culture on the root element, which is most probably the outer most Grid element, of your XAML.

For example: Set the culture in the corresponding ViewModel constructor (in a MVVM architecture):

this.View.MainGrid.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);

Sources

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.