Search code examples
c#wpfxaml

Resources.resx not loading in WPF


I try to make my application multilingual. For this I have created two resource files:

  • Resource.de-DE.resx
  • Resource.en-US.resx

Both are set to public and contain the same keyword and translation. I can also access the keywords in the backend -> see image. Unfortunately my program does not load the files when I change the language.

My steps:

  1. set the default Resources.resx to public.
  2. copied this file twice
  3. renamed file to (see above)
  4. keywords+translation entered and checked
  5. project created again
  6. included on the Button-Content by:
<Button x:Name="Home_Button" Style="{DynamicResource Menuebutton}"  Content="{x:Static p:Resources.Menue_home}" Click="Home_Click"/>
  1. access of the object set by:
xmlns:p="clr-namespace:VS_Launcher.Properties"
  1. include in the MainWindow.xaml.cs by:
CultureInfo myCultureInfo = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentCulture = myCultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = myCultureInfo;
Thread.CurrentThread.CurrentCulture = myCultureInfo;
Thread.CurrentThread.CurrentUICulture = myCultureInfo;

In another project I did the same thing. But there the solution worked. What is my error?

Resource Files Directory structure


Solution

  • Are you sure the file names of alternative language resources (excluding culture-locale) are identical with default one? If the default one is Resources.resx, alternative ones must be like:

    • Resources.de-DE.resx
    • Resources.en-US.resx