WP7/Silverlight]在列表框中绑定远程图像,这样 UI 就不会被阻塞

编程入门 行业动态 更新时间:2024-10-24 18:17:14
本文介绍了WP7/Silverlight]在列表框中绑定远程图像,这样 UI 就不会被阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

(场景:Windows Phone 7/Silverlight)

我有一个列表框,我将把它简化为这个 XAML:

<!-- ImageLinks ViewModel 中的一个集合--><ListBox.ItemTemplate><数据模板><Image Source="{Binding Path=ImageSource}"/><!-- ImageSource 是带有图像 url 的字符串--></数据模板></ListBox.ItemTemplate></列表框>

现在,上面的代码可以工作,但问题是当项目被渲染/加载或开始下载图像时,它会阻止 UI.而且由于同时适合多个项目,因此在下载所有相应的图像之前,UI 会被阻止.

那么,问题是,如何在下载图像时不阻止 UI 的情况下获得此功能(并避免每次导航到视图时都重新下载所有图像)?..>

提前致谢.

问题解决了,感谢所有花时间帮助我的人.

解决方案

延迟正好解决了这个问题.
请参阅他关于该主题的博客条目 http://blogs.msdn/b/delay/archive/2010/09/02/keep-a-low-profile-lowprofileimageloader-helps-the-windows-phone-7-ui-thread-stay-responsive-by-loading-images-in-the-background.aspx

(Scenario: Windows Phone 7 / Silverlight)

I have a ListBox that i will simplify to this XAML:

<ListBox ItemsSource="{Binding Path=ImageLinks}"> <!-- ImageLinks a collection in ViewModel -->
    <ListBox.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding Path=ImageSource}" /> <!-- ImageSource is a string with the url to the image-->
                </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Now, the above code works, but the problem is that as the item is rendered/loaded or whatever it starts downloading the image but while doing so, it blocks the UI. And since more than one item fits at the time, the UI gets blocked until all of the corresponding images are downloaded.

So, the question is, how do i get this functionality without the UI being blocked while downloading the images (and avoiding redownloading all of them each time the view gets navigated to)?.

Thanks in advance.

Well problem Solved, Thanks to all of you who took the time to help me.

解决方案

Delay created a solution to exactly this problem.
See his blog entry on the topic at http://blogs.msdn/b/delay/archive/2010/09/02/keep-a-low-profile-lowprofileimageloader-helps-the-windows-phone-7-ui-thread-stay-responsive-by-loading-images-in-the-background.aspx

这篇关于WP7/Silverlight]在列表框中绑定远程图像,这样 UI 就不会被阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 15:29:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1119323.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   框中   图像   列表   Silverlight

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!