WPF:如何更改的CurrentUICulture在运行时 [英] WPF: How to change the CurrentUICulture at runtime

查看:208
本文介绍了WPF:如何更改的CurrentUICulture在运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变我的WPF应用程序使用一个click事件的语言,但它不会改变。

 私人无效menuItemGerman_Click(对象发件人,RoutedEventArgs E)
    {
        Settings.Default.Culture =去DE;

        Thread.CurrentThread.CurrentCulture =新的CultureInfo(Settings.Default.Culture);
        Thread.CurrentThread.CurrentUICulture =新的CultureInfo(Settings.Default.Culture);
    }
 

我在想什么?

解决方案
  

我在想什么?

pretty的每样东西。你改变了与线程注册的文化。

还等什么?每个使用中的String.Format现在就用这个​​。

坏消息:WPF不关心在这一点上。你需要重新加载在WPF层次中的所有本地化项目。

<一个href="http://blogs.microsoft.co.il/blogs/tomershamam/archive/2007/10/30/wpf-localization-on-the-fly-language-selection.aspx" rel="nofollow">http://blogs.microsoft.co.il/blogs/tomershamam/archive/2007/10/30/wpf-localization-on-the-fly-language-selection.aspx

有更多的信息。

I am trying to change the language my WPF app uses in a click event but it doesn't change.

   private void menuItemGerman_Click(object sender, RoutedEventArgs e)
    {
        Settings.Default.Culture = "de-DE";

        Thread.CurrentThread.CurrentCulture = new CultureInfo(Settings.Default.Culture);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Culture);
    }

What am I missing?

解决方案

What am I missing?

Pretty much everything. You changed the culture registered with the thread.

So what? Every use to String.Format will use this now.

Bad news: WPF does not care at this point. YOu need to reload all localized items in the WPF hierarchy.

http://blogs.microsoft.co.il/blogs/tomershamam/archive/2007/10/30/wpf-localization-on-the-fly-language-selection.aspx

has more information.

这篇关于WPF:如何更改的CurrentUICulture在运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆