如何在Windows Phone 7应用程序中显示来自互联网的图像?

Vay*_*age 1 c# silverlight windows-phone-7

我正在制作一个应用程序,通过解析RSS提要来获取图像的网址.我想在屏幕上点击时依次在应用程序中显示这些图像.我该怎么办?是否需要在显示前下载所有图像?请解释.

感谢致敬

vaysage

tho*_*sen 8

也许我没有正确理解你的问题,但你应该能够将Image元素的Source直接设置为RSS feed项中指定的URI.

<Image x:Name="m_Image" Source="http://www.microsoft.com/silverlight/images/ms-silverlight-logo.png"/>
Run Code Online (Sandbox Code Playgroud)

更改项目(通过点击)时,您可以轻松地从代码中交换图像源.

Uri uri = new Uri("...", UriKind.Absolute);
ImageSource imgSource = new BitmapImage(uri);
m_Image.Source = imgSource;
Run Code Online (Sandbox Code Playgroud)

使用LowProfileImageLoader(如Thomas Joulin和Mick N所述)是一种在后台加载图像并保持UI响应的好方法.