Reputation: 6888
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)?
Upvotes: 1
Views: 254
Reputation: 1862
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" />
Upvotes: 3