I'm trying to switch application language at application runtime by using x:Uid and resx.
I have already set up the cultureinfo to the language I want in App.cs.
CultureInfo culture = new CultureInfo("zh-CN");
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
Thread.CurrentThread.CurrentCulture = culture;
and I have some string under /Language/zh-CN/Resources.resx
file.
Control_ConnectButton.Content 连接
Control_TestButton.Content 测试
Button xaml
<Button x:Name="ConnectButton" x:Uid="Control_ConnectButton" VerticalAlignment="Center"
Click="ConnectButton_Click" Margin="28,0,0,0" MinWidth="70" />
<Button x:Name="TestButton" x:Uid="Control_TestButton" VerticalAlignment="Center"
Click="TestButton_Click" Margin="28,0,0,0" MinWidth="70" />
However when I start the application, the text on the button is empty.
What did I do wrong?
I'm using .NET Framework 4.6.1
question from:
https://stackoverflow.com/questions/65881929/wpf-localization-using-xuid-and-resx 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…