我在App.xaml
主程序集中有一个合并的资源字典,它结合了来自不同程序集的各种资源字典:Common和PresentationLayer。
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Common;component/Themes/Button.xaml"/>
<ResourceDictionary Source="/PresentationLayer;component/DataTemplates/AppointmentsDataTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
在运行时,资源字典中的样式会正确应用到控件上。但是,在设计时,样式不会被应用,Visual Studio 2012 会持续报以下错误:
An error occurred while finding the resource dictionary "/Common;component/Themes/Button.xaml".
并且警告:
The resource "BannerButton" could not be resolved.
我看到了这篇文章,但即使将Build Action设置为Resource,问题仍然存在。并且,在Visual Studio 2010或Expression Blend 4下运行时,我没有遇到这个问题。主程序集明确引用了Common程序集,并且我没有改变Pack URIs。