I have been playing around WPF recently and I want to know how to use English culture resources even when the app culture is set to another culture say Arabic.
I have defined two resource files containing the HelloWorld key under a Resources folder.
- AppResources.resx (Has HelloWorld = Hello World!)
- AppResources.ar.resx (Has HelloWorld = مرحبا بالعالم)
HomePage.xaml
First I have declared the resource file's namespace as res
xmlns:res="clr-namespace:Demo.Core.Resources;assembly=Demo.Core"
and then used it in the label to show Hello World!
<Label Content="{x:Static res:AppResources.HelloWorld}"/>
I have set Arabic as the app culture
CultureInfo cultureInfo = new CultureInfo("ar");
Resources.AppResources.Culture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
I want to show the English Hello World! But it is showing the Arabic hello world (مرحبا بالعالم)
This is because I have set the CurrentUICulture & AppResources culture to Arabic. Is there any way with these setting, I could get still use the English strings defined in AppResources.resx file as it is in XAML? Basically, I want to ignore the culture setting and want to use the English resource directly in the XAML. Thanks in advance.