Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show an Image resource in a WPF window defined in a class library

Tags:

resources

wpf

I have seen this thread: WPF image resources and applied the information there. But my situation seems a bit more tricky:

  • Assembly A is a class library
    • contains Dialog.xaml
      • this is a WPF window
    • contains Images/i.gif
  • Assembly B is a WPF application
    • shows Dialog.xaml

In my dialog, I have tried specifying the image in the following ways:

<Image Source="/Images/i.gif"/>

and

<Image Source="pack://application:,,,/Images/i.gif"/>

both work, but only in the designer!

Next, I added two and two together to yield:

<Image Source="pack://application:,,,A;;content/Images/i.gif"/>

but this shows the same symptoms:

As soon as I start the application, the images seem to be not found. I don't know for sure, since I get no error message. They just don't show up.

Any ideas?

like image 944
Daren Thomas Avatar asked Dec 02 '10 18:12

Daren Thomas


1 Answers

You appear to be missing the required word "Component" form the beginning of your path, e.g.

pack://application:,,,/YourAssembly.Name;Component/Images/PlusGreen.png

like image 197
Tim Lloyd Avatar answered Nov 03 '22 20:11

Tim Lloyd