简体   繁体   中英

WPF Localization not working from code behind

I have two resource files: StaticData.resx and StaticData.de-ch.resx

After I change my CultureInfo, the UI reflects the change perfectly.

var culture = new CultureInfo(Settings.Default.Localization);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;

XAML

Title="{x:Static language:StaticData.Title}"

When I try to access this from my code behind, I only get the data from StaticData.resx

var title = StaticData.Title;

What am I doing wrong? According to this link it's supposed to work.

As the var title = StaticData.Title; was called from a different Thread the CultureInfo Need to we set to the correct format again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM