Windows8 - 在C#中使用本地化字符串

Krz*_*zor 9 c# xaml microsoft-metro windows-8

我的本地化应用程序存在问题.我有文件Resources.resw,其中包含字符串"noResults.Text"(它以.Text结尾,因为我在xaml中使用它来处理textblock(x:Uid))问题是我想在代码后面使用相同的字符串( C#)我如何访问它?我尝试过这样的事情:

resourceLoader.GetString("noResults");
resourceLoader.GetString("noResults.Text");
Run Code Online (Sandbox Code Playgroud)

但这一切都没有

提前致谢 :)

Gam*_*bit 24

做这样的事情:

var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
string result = loader.GetString("noResults/text");
Run Code Online (Sandbox Code Playgroud)

请注意,在您的资源中,如果您使用的是"noResults.text",请不要将另一个字符串定义为"noResults"(无扩展名).

  • Microsoft会在任何地方记录此信息 (3认同)