找不到 DLL 中图像的合并资源字典文件夹

Merged Resource Dictionary folder of images in DLL not found

这里是 WPF 进程的新手,并尝试定义一个合并字典,该合并字典包含在实用程序 DLL 中维护的一组合并字典。我正在尝试解决资源位置错误。

错误

Theme.xaml

<ResourceDictionary       
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/UI/WPF/ImageList16x16.xaml"  />
        <!--Future xaml file references-->
    </ResourceDictionary.MergedDictionaries>
    <Style x:Key="EmptyStyle"/>
</ResourceDictionary>

ImageList16x16.xaml

<ResourceDictionary         
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:clr="clr-namespace:System;assembly=mscorlib">

    <BitmapImage x:Key="Accept" UriSource="UI/Resources/Images16x16/accept.png"/>
</ResourceDictionary>

用户控件资源参考

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/BHP_Utilities;component/UI/WPF/Theme.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>

执行时,根据其中的字典引用,发现Theme.xaml出现错误。两个 xaml 文件的 build 选项PageCustom Tool 属性 设置为 XamlIntelliSenseFileGenerator

由于文件在同一个文件夹中,您可以尝试删除“/UI/WPF/”

<ResourceDictionary Source="ImageList16x16.xaml"  />