【发布时间】:2012-08-17 02:07:06
【问题描述】:
如何在字符串路径上设置背景?
canvas1.Background = "/path/";
请帮忙!!!谢谢:)
【问题讨论】:
如何在字符串路径上设置背景?
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))) };
【讨论】: