如何在字符串路径上设置背景?
canvas1.Background = "/path/";
请帮忙!!!谢谢 :)
我认为您正在寻找ImageBrush类:
ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri(@"/path/", UriKind.Relative));
canvas1.Background = imageBrush;
用这个
mycanvas.Background = new ImageBrush()
{ ImageSource = new BitmapImage((new Uri(mypath, UriKind.Absolute))) };