LongListSelector 是否为我们做延迟加载? [英] Does LongListSelector make Lazy Load for us?

查看:46
本文介绍了LongListSelector 是否为我们做延迟加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 windows phone 8 项目中,在这个项目中,我使用全景模板.在第一个全景图中,我在长列表选择器中显示新闻.

I'm on windows phone 8 project, in this project, I use panorama template. In first panorama I show the news in a longlistselector.

首先,我展示了 15 条新闻,没有任何性能问题.但是现在我显示了 50 条新闻,并且我认为加载时间开始变长.

First, I was showing 15 news and nothing was a problem for performance. But now I show 50 news and started to make load time longer I think.

我的问题是,longlistselector 为我们做延迟加载,还是我们应该为它做一些像 windows 商店一样的东西.或者我的意思是,当我滚动底部时,它会得到小图片和标题?

My question is, longlistselector make lazy loading for us or should we make something for it like windows stores one. Or I mean, When I scroll bottoms, It gets the small pictures and titles ?

我已经达到了 ItemRealized 和 UnRealized 事件.我应该关注他们吗?

I've reached ItemRealized and UnRealized events. Should I focus on them ?

顺便说一下,我没有正确使用 MVVM.我从 web api 获取数据并将其绑定到控件.

By the way, I don't use MVVM correctly. I get the data from web api and binds it to controls.

推荐答案

您可以使用 OnItemRealized 事件实现延迟加载,请看这里 http://www.damirscorner.com/InfiniteScrollingWithIncrementalLoadingInWindowsPhone8.aspx

You can achieve lazy-loading using the OnItemRealized event, take a look here http://www.damirscorner.com/InfiniteScrollingWithIncrementalLoadingInWindowsPhone8.aspx

private void OnItemRealized(object sender, ItemRealizationEventArgs e)
{
    var longListSelector = sender as LongListSelector;
    if (longListSelector == null)
    {
        return;
    }

    var item = e.Container.Content;
    var items = longListSelector.ItemsSource;
    var index = items.IndexOf(item);

    if (items.Count - index <= 1)
    {
        //ask for more items and add theme here
    }
}

这篇关于LongListSelector 是否为我们做延迟加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆