本文介绍了WP7/Silverlight]在列表框中绑定远程图像,这样 UI 就不会被阻塞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(场景:Windows Phone 7/Silverlight)

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

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

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

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

提前致谢.

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

解决方案

延迟正好解决了这个问题.
请参阅他关于该主题的博客条目 http://blogs.msdn.com/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.com/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 就不会被阻塞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 13:34