change culture using wpflocalizeextension

2019-05-11 19:44发布

问题:

maybe it's very simple, but how to change the culture in code behind to allow the wpflocalizeextension to show the desired resource?

I tried to change the application culture, but it did nothing!!

回答1:

In order to change the current culture at runtime you use the following two statements. With SetCurrentThreadCulture, also the culture of the current thread is updated.

WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.Culture = new CultureInfo("en");

To get a list of available CultureInfo objects, you can use

WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.MergedAvailableCultures


回答2:

Try something like this?

CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");