Silverlight.WebClient下载

Silverlight.WebClient下载,第1张

概述System.Net.WebClient 是我们在客户端常用下载对象,image也是sl中出镜率较高的控件 再加上一个MediaElement控件,让我们就此实现一个会动的silverlightLOGO吧~ xaml的组成很简单: <UserControl x:Class="SilverlightApplication1.Page"      xmlns="http:

System.Net@[email protected] 是我们在客户端常用下载对象,image也是sl中出镜率较高的控件
再加上一个MediaElement控件,让我们就此实现一个会动的silverlightlogo吧~



xaml的组成很简单:@H_301_9@

  <UserControl x:Class="SilverlightApplication1.Page"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"          WIDth="400" Height="300"        <Canvas Background="White"            <MediaElement WIDth="50" Height="50" Autoplay="True" x:name="myMp"/>             <Image x:name="myImage" WIDth="150" Height="50" Canvas.left="60" ></Image>         </Canvas>     </UserControl>   

@H_301_9@

接下来我们将 Image绑定图片:@H_301_9@

    new BitmAPImage(new Uri("PropertIEs/microsoft_silverlight_c - copy.jpg", UriKind.relative));     

随后声明WebClIEnt对象和注册委托事件:
webClIEnt.openReadAsync()方法参数
1.位于服务器上的数据源的路径.
2.给与用户一个标识对本次访问服务器.

    WebClIEnt wc = new WebClIEnt();       wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);       wc.OpenReadAsync(new Uri("Silverlightlogo.zip", UriKind.relative), "Silverlightlogo.wmv");                      voID wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)              {                  //读取数据完成              }     

当下载数据完成后回调openreadcompleted方法

我们可以从参数e中得到有用的数据

    String sURI = e.UserState as String;       StreamResourceInfo zipResourceInfo = new StreamResourceInfo(e.Result as Stream, null);       StreamResourceInfo imageResourceInfo = Application.GetResourceStream(zipResourceInfo, new Uri(sURI, UriKind.relativeOrabsolute));       myMp.SetSource(imageResourceInfo.Stream);     

就这样我们已将一个会动的silverlightlogo展现给用户了,很简单吧~
@H_301_9@

Source code: download.@H_301_9@

@H_301_9@ 总结

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

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存