1

how i can set background on string path?

canvas1.Background = "/path/";

please help!!! thanks :)

Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
JohnSmith
  • 59
  • 1
  • 7

2 Answers2

3

I think you are looking for the ImageBrush class:

ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri(@"/path/", UriKind.Relative));
canvas1.Background = imageBrush;
nemesv
  • 138,284
  • 16
  • 416
  • 359
1

Use this

mycanvas.Background = new ImageBrush() 
          { ImageSource = new BitmapImage((new Uri(mypath, UriKind.Absolute))) };
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208