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

本文关键字:本地化 字符串 Windows8- | 更新日期: 2024-06-14 03:01:23

我在本地化应用程序时遇到问题。我有一个文件Resources.resw,里面有字符串"noResults.Text"(它以.Text结尾,因为我在xaml中为textblock(x:Uid)使用它)问题是我想在代码隐藏中使用相同的字符串(C#)我如何访问它?我试过这样的东西:

resourceLoader.GetString("noResults");
resourceLoader.GetString("noResults.Text");

但这些都不起作用

提前感谢:)

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

这样做:

var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
string result = loader.GetString("noResults/text");

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