views:

20

answers:

2

I have 3 assemblies:

Number 1- ResourceAssembly which contains a subfolder Images with 1 image in it (build action = resource). Within that subfolder is a ResourceDictionary with build action set to resource. The resource dictionary contains the following-

<BitmapImage x:Key="BluePlus_48x48_72" UriSource="112_Plus_Blue_48x48_72.png"/>

Number 2 - A wpf control assembly with a single usercontrol called UserControl1. Within that usercontrol's resources, I am loading the resource dictionary from assembly 1 and using the image in it.

<ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/ResourcesAssembly;component/Images/ImagesDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

<Image Source="{DynamicResource BluePlus_48x48_72}" Height="48" Width="48"/>

The image appears correctly.

Number 3 - The main application assembly. Within the MainWindow.xaml, I reference the Project1 assembly and insert a UserControl1.

xmlns:p1="clr-namespace:Project1;assembly=Project1"
<p1:UserControl1 Height="60" Width="60"/>

However, the image does not appear. There are no compile-time errors nor any errors ouput to the Output window at runtime. I am at a loss as to why the image isn't appearring. Any thought?

Thanks for your help!

A: 

Try giving the resource reference like below.

<ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/YourAssembly.Name;component/Images/ImagesDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

<Image Source="{StaticResource BluePlus_48x48_72}" Height="48" Width="48"/>

Note: Also, don't forgot the / in Source="/ .

HTH

Avatar
A: 

I think you'll need to also add a reference to the "ResourceAssembly" project in your main application. Or at least have the "ResourceAssembly.dll" in the same folder as your main application's executable.

karmicpuppet
It boiled down to moving the ResourceAssembly.dll assembly into the application directory as stated. Thanks!
chad easterling