Loading

WPF中添加资源报错“无法StaticExtension 值解析为枚举、静态字段或静态属性”的解决方法

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”。再次编译运行程序,即可解决所述问题。

         

 

 

 

  

 

posted @ 2020-04-27 15:31  Dwaynerbing  阅读(1032)  评论(0编辑  收藏  举报