如何在运行时从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更改后,日历的本地化不会更改 - 它需要重新启动应用。