XAML 未在WPF中加载资源.resx

dw1jzc5e  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(203)

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 FilesDirectory structure

e3bfsja2

e3bfsja21#

您确定替代语言资源(不包括文化特性区域设置)的文件名称与预设的文件名称相同吗?如果预设的文件名称是Resource s.resx,则替代的文件名称必须是:

  • 资源s.取消DE.resx
  • 资源s.en-US.resx

相关问题