WPFToolkit日历更改语言

时间:2017-03-11 13:09:28

标签: wpf localization calendar runtime

如何在运行时从WPFToolkit库更改日历控件的语言?

XAML:

<toolkit:Calendar Style="{StaticResource CalendarStyle1}"/>

C#

public MainWindow()
{
    InitializeComponent();
    App.LanguageChanged += App_LanguageChanged;
    Thread.CurrentThread.CurrentCulture = new CultureInfo(App.Language.ToString());
    Thread.CurrentThread.CurrentUICulture = new CultureInfo(App.Language.ToString());
}

private void App_LanguageChanged(object sender, EventArgs e)
{
    Thread.CurrentThread.CurrentCulture = new CultureInfo(App.Language.ToString()); ;
    Thread.CurrentThread.CurrentUICulture = new CultureInfo(App.Language.ToString());
}

这仅允许在应用开始时本地化日历,但在App.Language更改后,日历的本地化不会更改 - 它需要重新启动应用。

0 个答案:

没有答案