使用Silverlight2的WebClient下载远程图片
来源:互联网 发布:怎样注册开淘宝网店 编辑:程序博客网 时间:2024/04/30 20:00
在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下载远程图片
- c# WebClient 下载远程图片--超简单
- WebClient使用DownloadDataCompleted异步下载图片
- WebClient下载图片示例
- WebClient 类的使用和下载文件
- 使用WebClient实现下载
- 使用WebClient下载
- WebClient 从网上下载图片
- WebClient方法示例下载远程数据
- 使用WebClient实现文件下载
- 使用WebClient实现文件下载
- 使用WebClient实现文件下载
- 使用.net里的WebClient自动下载baidu的mp3
- WebClient运用(下载图片,文件)
- php下载远程的图片
- WebClient类的下载方法
- WebClient类的使用
- WebClient的使用问题
- SIP-I和SIP-T的比较
- 有关于NBear的简介
- ashx是什么文件,如何创建
- 还是php验证中文的问题
- java动态代理
- 使用Silverlight2的WebClient下载远程图片
- mips学习
- 如何使用SetTimer MFC
- 海螺丝作法
- C++中Cstring使用小结
- GWT项目经验总结与感想
- ARP概念及攻击与防护的原理
- 高精度_大数除模小数运算
- VC通用控件编程之CImageList控件