Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wpf canvas background image dynamically

In my application I want the user to load an image as the canvas background. How can I assign the image to canvas background?

like image 440
Hasan Zubairi Avatar asked Apr 03 '12 03:04

Hasan Zubairi


1 Answers

Use ImageBrush to set Canvas.Background property

ImageBrush ib = new ImageBrush();
ib.ImageSource = new BitmapImage(new Uri(@"sampleImages\berries.jpg", UriKind.Relative));
mycanvas.Background = ib;
like image 130
Nikhil Agrawal Avatar answered Oct 19 '22 00:10

Nikhil Agrawal