XAML don′t know the Resource folder
我试图从Resources.resx在XAML中设置一个Icon,但是找不到资源。
码:
1 2 3 4 | .... xmlns:resx="clr-namespace:Admin_Overwatch.Properties" Title="MainWindow" Height="400" Width="600" Icon="{x:Static resx:Resources.TitelLogomRand1}"> |
错误:
"名称空间中不存在名称" Resources"。
有趣的是,在自动套用格式中,它会在资源文件中找到每个图标。 我有重建它没有成功,并尝试了新的Resource文件夹也没有成功。
为什么找不到文件夹?
编辑:
我也尝试了本教程,但没有成功,出现了同样的错误,找不到资源。
http://social.technet.microsoft.com/wiki/contents/articles/22420.binding-to-resources-resx-files-in-xaml.aspx
答案是除了常规的clr外还使用Assembly:
1 2 | xmlns:resx="clr-namespace:Admin_Overwatch.Properties;assembly=Admin-Overwatch" xmlns:local="clr-namespace:Admin_Overwatch;assembly=Admin-Overwatch" |
大会名称可以通过以下方式找到
右键单击属性->应用程序下的项目名称。
但是重要的部分是不可能从只能以win形式出现的wpf中的resx加载图片。
看这里:
如何使用Resources.resx链接图像