将资源字符串设置为XAML

我知道如何从资源中设置字符串
其中Text1.Text为“Hello”

但我想这样做

  

其中GreetingText是“你好”

这样我也可以从代码中获得相同的字符串

 var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); var string = loader.GetString("GreetingText"); 

Nikhil的答案是正确的,但适合其他平台。

对于Windows 8,您需要在资源目录中执行以下操作:

 This is a resource 

在你的xaml中:

  

在代码中:

 string myString = (string)(App.Current.Resources["MyString"]); 

包括这个

 xmlns:system="clr-namespace:System;assembly=mscorlib" 

有一个system:string资源system:string

  Hello  

并在xaml中使用它

  

并在后面的代码中使用它

 string s = (string)objectofMainWindow.Resources["GreetingText"]; 

编辑:回答您的评论

就是这样。 资源字典在Window.Resources

    Hello   Your Code