我有两个资源词典并尝试添加
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Skins/MainSkin.xaml"/>
<ResourceDictionary Source="/Skins/Expander.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
如果我尝试在资源中添加转换器,那么它将找不到字典。
答案 0 :(得分:2)
如果你有这个:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Skins/MainSkin.xaml"/>
<ResourceDictionary Source="/Skins/Expander.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
然后,您将该特定ResourceDictionary分配给UserControl.Resources属性。如果要在合并的词典之外添加其他资源,则必须将它们添加到ResourceDictionary中,如下所示:
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Skins/MainSkin.xaml"/>
<ResourceDictionary Source="/Skins/Expander.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- TODO: Add items here -->
</ResourceDictionary>
<!-- NOTE: You can't add items here -->
</UserControl.Resources>