Access images for my project when it is embedded in another project

Posted by Vaccano on Stack Overflow See other posts from Stack Overflow or by Vaccano
Published on 2012-06-12T22:42:33Z Indexed on 2012/06/13 4:40 UTC
Read the original article Hit count: 168

Filed under:
|
|
|
|

I have the following situation:

  • ProjectA needs to show an image on a UserControl.
    It has the image in its project (can be a Resource or whatever).

  • But ProjectA is just a dll. It is used by ProjectB (via Prism).

So doing this in ProjectA works for design time (if the MyImage.png file is set to "Resource" compile action):

<Image Source="pack://application:,,,/ProjectA;component/MyImage.png"></Image>

But at run time, all that is copied to ProjectB is the dll (and that is all I want copied. So MyImage.png is present in the running folder... and it does not show an image.

I thought that Making it Resource would embed it but it does not seem to work.

I also tried to use a Resources.resx and that does not seem to work at all (or I can't find the way to bind the image in xaml).

How can I put the image inside my dll and then reference it from there (or some other non-file system dependent way to get the image)?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wpf