tags:

views:

4216

answers:

3

I am trying to add a png image resource in a specific Silverlight project folder. I would like to refer to this image with in my tag? I only seem to get this working when the xaml file containing the image tag is located in the same directory as the png file.

For example in the xap file the png file would be located in xap\resource\image1.png and my xaml file would reside in the root directory xap\consumeImageA.xaml.

A: 

You can specify a relative path from where the XAP file resides, but you can't use .. notation so the images would have to be at the level of the XAP file or lower. Shawn Wildermuth has been playing with putting the XAP file at the web root instead of ClientBin so that you can use relative paths. Alternatively, you can use an absolute path to the image.

Bill Reiss
A: 

Make sure you use forward slashes, not back slashes. I know that one has bit me in the rear more than once.

So, in your example, you should use resource/image1.png

Matt Casto
+1  A: 

I have found a blog post discussing USING URIS IN EXPRESSION BLEND which works for me.

  • pack://application:,,,/Images/happyface.png is wrong. This will work from XAML,
    but not from code. It needs to be

  • pack://application:,,,/WpfApplication6;component/Images/happyface.png If you do this, Blend resolves well
    all the time!

Aaron Fischer