如何在Silverlight中将资源字符串绑定到Xaml

3 data-binding silverlight xaml

如何在Silverlight中将资源字符串绑定到Xaml?

小智 6

您需要将此引用添加到App.xaml

xmlns:sys="clr-namespace:System;assembly=mscorlib" 
Run Code Online (Sandbox Code Playgroud)

然后你需要将字符串添加到该<Application.Resources>部分

<sys:String x:Key="ResourceString">Resource String</clr:String>
Run Code Online (Sandbox Code Playgroud)

然后你需要做的就是参考*{StaticResource ResourceString},例如:

<TextBlock Text="{StaticResource ResourceString}"></TextBlock>
Run Code Online (Sandbox Code Playgroud)