WPF XAML Bindings and CurrentCulture Display

It turns out that WPF does not respect the CurrentCulture by default in bindings, and instead defaults to xml:Lang setting defined in the XAML document or en-US if not provided. This is rather lame behavior – not sure why you would NOT have automatic culture formatting applied as every other UI technology, but…

Luckily there’s an easy workaround that can be applied in the document’s constructor or a Window/UserControl base class:

        // MAKE SURE you set the language of the page explicitly or else
        // all number and date formatting occurs using 
        this.Language = XmlLanguage.GetLanguage(
                        CultureInfo.CurrentCulture.IetfLanguageTag);

There’s more information available in this blog post:

http://www.west-wind.com/weblog/posts/796725.aspx

Leave a Comment