views:

51

answers:

1

I have an image (embedded resource) that i can get access to and form an Image object from. I actually can get the Image object or the Stream of bits the represent the image. However I want to sue that image programaticly to be a background image.

So how do I set the ImageSource on the ImageBrush to an AcutalImage (PNG)?

A: 

Hi,

I think the MSDN documentation says it all:

http://msdn.microsoft.com/en-us/library/system.windows.media.imagebrush.imagesource%28VS.95%29.aspx

You can either set the source as a URI in XAML, or use code behind to set it to an ImageSource object created from a stream or a Uri, e.g.

_imageBrush.ImageSource = new BitmapImage(new Uri("http://someurl.com/images/myimage.png"));

Cheers, Alex

EDIT: If your image is a ressource, you can use the ressource url syntax:

"/{AssemblyName};component/{RelativePath}"

For example:

<ImageBrush ImageSource="/MyApplication.Resources;component/Images/image1.png" />
alexander.biskop
How deos one get the UIR of an embedded reource?
akaphenom
Ahhh - excellent - thank you very much.
akaphenom