【发布时间】:2014-10-06 20:22:09
【问题描述】:
我正在尝试将图像添加到我的 WPF 应用程序画布中。 据我了解,它们需要在 VS 解决方案中作为资源引用。 但是,我需要能够将图像复制到文件夹中,并从 XML 文件中解析图像的相对 Uri,并将图像加载到画布中:
Image image = new Image();
var pic = new BitmapImage();
pic.BeginInit();
pic.UriSource = new Uri(url, UriKind.Relative); // url is from the xml
pic.EndInit();
image.Source = pic;
LayoutRoot.Children.Add(image); //since the image is not in VS marked as Resource,
// nothing shows up
感谢您的善意建议
【问题讨论】: