我的问题与这个非常相似
我有许多项目的解决方案。其中有两个是相关的:一个包含 WPF 窗口的类库和一个包含所有 WPF 样式的项目。
项目 1 中带有窗口的类库
Window 的合并字典类似于:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/StyleAssembly;component/CommonStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
//other styles here
项目 2中的 CommonStyle.xaml :
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Components/Type/CheckBox.xaml"/>
</ResourceDictionary.MergedDictionaries>
这会导致如下错误:
{“找不到资源‘components/type/checkbox.xaml’。”}
但是,如果我在项目 1 中创建一个 CommonStyle.xaml 并从项目 2 中引用相同的控件样式,那么它就可以工作。
如何使最高级别的 xaml 文件 (CommonStyle.xaml) 从项目 2 中工作?