Reputation: 59
how i can set background on string path?
canvas1.Background = "/path/";
please help!!! thanks :)
Upvotes: 1
Views: 6550
Reputation: 48558
Use this
mycanvas.Background = new ImageBrush()
{ ImageSource = new BitmapImage((new Uri(mypath, UriKind.Absolute))) };
Upvotes: 1
Reputation: 139748
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;
Upvotes: 3