- 引用 xmlns:sys="clr-namespace:System;assembly=mscorlib"
<Window.Resources>
<sys:String x:Key="myString">Hello Wpf Resource</sys:String>
</Window.Resources>- 前台绑定:
<TextBox Grid.Column="0" Grid.Row="0" x:Name="txtName" Text="{StaticResource ResourceKey=myString}" Grid.ColumnSpan="2"></TextBox>
- 后台访问:String str = this.FindResource("myString").ToString();