tags:

views:

57

answers:

1

HI all!

I am wondering that could I load a image from xaml file? I mean that, for example: I have a folder IMAGES that contains all of my images.These images were not added to my project.At an xaml file I try to load an image.like bellow code:

<Image Source="/IMAGES/gift.png" Height="70" Width="70" VerticalAlignment="Top" />

Could I do that? or I have to load this in behind code?

thanks in advanced

+1  A: 

You can use Pack URIs with siteoforigin authority like this:

<Image Source="pack://siteoforigin:,,,/IMAGES/gift.png" 
       Height="70" Width="70" VerticalAlignment="Top" />
Miroslav Popovic
It doesnt run. Because gift.png wasnt added to my project.
huynq9
I just tried it with an image located under my Debug folder.Note that the path needs to be relative to the running assembly. So if your compiled exe is in \bin\Debug folder, file needs to be in \bin\Debug\IMAGES\gift.png.
Miroslav Popovic