1

如何在字符串路径上设置背景?

canvas1.Background = "/path/";

请帮忙!!!谢谢 :)

4

2 回答 2

3

我认为您正在寻找ImageBrush类:

ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri(@"/path/", UriKind.Relative));
canvas1.Background = imageBrush;
于 2012-08-16T18:01:05.757 回答
1

用这个

mycanvas.Background = new ImageBrush() 
          { ImageSource = new BitmapImage((new Uri(mypath, UriKind.Absolute))) };
于 2012-08-16T18:07:06.140 回答