1:问题描述
(1)添加资源。在方案的资源中加入以下字符串资源:
(2)声明使用资源。在xaml中引入资源引用名称“xmlns:prop="clr-namespace:chapter10.Properties”,并使用之:
<TextBlock Text="{x:Static prop:Resources.UserName}"/> <TextBlock Text="{x:Static prop:Resources.Password}"/>
(3)运行程序。程序运行后,报错如下:
2:解决方案
将方案的Resources.resx文件右击显示“属性”,并将属性中的“自定义工具”前加上“Public”。再次编译运行程序,即可解决所述问题。