【发布时间】:2019-10-11 15:40:50
【问题描述】:
是否可以在单独的库(框架)项目中制作资源字典,然后在另一个库项目中引用它?在这个单独的项目中,我有一个想要使用它的 UserControl。
这就是我的解决方案的设置方式。
SharedProject 有资源字典,我在我的插件项目中引用它。然后我将我的插件库导出到 MainProject 并让它显示我的插件视图。
我有所有这些工作......除了我的字典。我尝试在每个视图中引用我的字典
<UserControl.Resources>
<ResourceDictionary x:Key="dictionary">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/InternalShared;component/Resources/Dictionary1.xaml"/>
<ResourceDictionary Source="pack://application:,,,/InternalShared;component/Resources/Dictionary2.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
但是当我尝试引用现有样式时...
<Button Command="{Binding CommandOpenFile}"
Style="{DynamicResource GenericButtonStyle}"
IsEnabled="{Binding IsEnabled}"
Content="Restore Window"
Height="Auto" />
但我得到资源“GenericButtonStyle”无法解析。这种情况在我尝试引用任何字典中的样式的任何地方都会发生。我不知道为什么。
谁能告诉我为什么会这样?我还需要在其他地方设置此声明吗?
【问题讨论】:
标签: wpf xaml resourcedictionary