tags:

views:

354

answers:

1

Hi all,

I have a wpf application and a class library(dll) project. In my dll I have an images folder with some .png files set as Resource.

I want to reference and display the image using the wpf main application.

Any ideas? I want to do this in the xaml not the code behind if at all possible.

Ta, Matt.

+1  A: 

Assuming you reference the class library from the WPF application you can reference and display the image in the WPF application with the following XAML:

<Image Source="/ClassLibraryName;Component/images/myimage.png"/>

The important thing here is "ClassLibraryName" which is the assembly name for your class library. "/images/myimage.png" is the path to your image.

You can find out more about WPF pack URIs here: http://msdn.microsoft.com/en-us/library/aa970069.aspx

b-rad
Superb. What does the "Component" have to be in there for?
Matt B
Ensure you have the "Build Action" for the resource set to "Resource" if you want to have the image embedded in the assembly. "Content" works as well if you don't want to have your images embedded.
Ashley Davis