在后台指定Image的source不是简单的传递一个路径的string就够了,目前所知,有两种方法:
第一种如MSDN所述:
Image myImage = new Image();
myImage.source = new BitmapImage(new Uri("myPicture.jpg",UriKind.RelativeOrAbsolute));
URL(例如,http://contoso.com/myPicture.jpg)来设置 Source,也可以指定相对于应用程序的 XAP 文件的 URL。
第二种效率就较低了,但是在某些情况下还比较有用:
string xxx = "<Image xmlns=/"http://schemas.microsoft.com/winfx/2006/xaml/presentation/" Source=/"" + imgPath + "/"></Image>";Image ig = (Image)System.Windows.Markup.XamlReader.Load(xxx);imgPath就是一个表示URL的string。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。