WPF:如何更改的CurrentUICulture在运行时 [英] WPF: How to change the CurrentUICulture at runtime
问题描述
我想改变我的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.
has more information.
这篇关于WPF:如何更改的CurrentUICulture在运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!