使用Silverlight2的WebClient下载远程图片

使用Silverlight2的WebClient下载远程图片,第1张

概述在Silverlight 2之前有一个Downloader对象,开发者一般使用Downloader下载图片和文体文件,这个对象在Silverlight 2中作为了一个特性被集成到WebClient类之中,你可以直接使用WebClient的OpenReadAsync方法加载远程图片的URI,然后使用OpenReadCompleted回调事件来返回Result,最后使用BitmapImage的SetS 在Silverlight 2之前有一个Downloader对象,开发者一般使用Downloader下载图片和文体文件,这个对象在Silverlight 2中作为了一个特性被集成到WebClIEnt类之中,你可以直接使用WebClIEnt的OpenReadAsync方法加载远程图片的URI,然后使用OpenReadCompleted回调事件来返回Result,最后使用BitmAPImage的SetSource方法声明位图文件的源即可!     代码如下: WebClIEnt webClIEntDownloader = new WebClIEnt(); webClIEntDownloader.OpenReadCompleted += new OpenReadCompletedEventHandler(webClIEntDownloader_OpenReadCompleted); webClIEntDownloader.OpenReadAsync(new Uri(String.Format("{0}/../Images/{1}",Application.Current.Host.source,imageSource))); webClIEntDownloader.OpenReadAsync(new Uri(String.Format("Images/{0}",imageSource))); voID webClIEntDownloader_OpenReadCompleted(object sender,OpenReadCompletedEventArgs e) { BitmAPImage bi = new BitmAPImage(); bi.SetSource(e.Result); image.source = bi; }
另外Beta2 中的图片动态设置的方法与Beta1不同               Image image = new Image();             Uri uri = new Uri(imageSource,UriKind.relative);             ImageSource img = new System.windows.Media.Imaging.BitmAPImage(uri);             imageBrush.SetValue(ImageBrush.ImageSourceProperty,img); 总结

以上是内存溢出为你收集整理的使用Silverlight2的WebClient下载远程图片全部内容,希望文章能够帮你解决使用Silverlight2的WebClient下载远程图片所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1054359.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存