Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3406596
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:38:49+00:00 2026-05-18T05:38:49+00:00

I have a .NET 4.0 WPF application where the user can change the language

  • 0

I have a .NET 4.0 WPF application where the user can change the language (culture)
I simply let the user select a language, create a corresponding CultureInfo and set:

Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;

In the C# code this works fine. However in the WPF controls the culture is still en-US. This means for example that dates will be shown in the US format instead of whatever is correct for the current culture.

Apparently, this is not a bug. According to MSDN and several blog posts and articles on StackOverflow the WPF language does not automatically follow the current culture. It is en-US until you do this:

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

See for example StringFormat Localization issues in wpf.

I do not completely understand what is going on here. It seems the Language property on all frameworkelements is set to the current culture. Anyway, it works. I do this when the application starts up and now all controls works as expected, and e.g. dates is formatted according to the current culture.

But now the problem: According to MSDN FrameworkElement.LanguageProperty.OverrideMetadata can only be called once. And indeed, if I call it again (when the user changes the language) it will throw an exception. So I haven’t really solved my problem.

The question: How can I reliably update the culture in WPF more than once and at any time in my applications life cycle?

(I found this when researching: http://www.nbdtech.com/Blog/archive/2009/03/18/getting-a-wpf-application-to-pick-up-the-correct-regional.aspx
and it seems he has something working there. However, I can’t imagine how to do this in my application. It seems I would have to update the language in all open windows and controls and refresh all existing bindings etc.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:38:50+00:00Added an answer on May 18, 2026 at 5:38 am

    I never found a way to do exactly what I asked for in the question.
    In my case I ended up solving it by having all my usercontrols inherit from a superclass that contained this:

    /// <summary>
    ///   Contains shared logic for all XAML-based Views in the application. 
    ///   Views that extend this type will have localization built-in.
    /// </summary>
    public abstract class ViewUserControl : UserControl
    {
        /// <summary>
        ///   Initializes a new instance of the ViewUserControl class.
        /// </summary>
        protected ViewUserControl()
        {
            // This is very important! We make sure that all views that inherit 
            // from this type will have localization built-in. 
            // Notice that the following line must run before InitializeComponent() on 
            // the view. Since the supertype's constructor is executed before the type's 
            // own constructor (which call InitializeComponent()) this is as it 
            // should be for classes extending this
            this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);
        }
    }
    

    When the user changes the language I then create new instances of any usercontrols that are currently running.

    This solved my problem. However, I would still like a way to do this “automatically” (i.e. without having to keep track of any instantiated objects).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have .NET WPF application and one of requirement is that user may select
I have a desktop .NET WPF application witch uses an embedded database (SQLite). Where
I have a .Net 4.0 WPF application that requires an embedded database. MS Access
We have created a beautifully designed .NET WPF desktop application. We are installing the
I have a WPF application (.NET 3.0, VS2008) that displays data in a tab
I have a WPF .NET 3.5 SP1 application that is in use on at
We have a .NET 4, WPF, WCF, EF 4, SQL 2008 application. One of
I have the problem when I create blank wpf .Net 3.5 project. Visual studio
I have a small-scale WPF application using VB.net as the code behind and I
All, I have a WPF application built upon SQLite database and user/application Configuration settings.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.