Add a Load More Button at the end of ListBox without losing Virtualization?

眉间皱痕 提交于 2019-11-29 11:23:20

I know this is an old post but in case some people stumble upon this:

There is a LongListSelector control available out of the box in WP8 or as part of the Windows Phone Toolkit for WP7 which supports this scenario quite neatly. If you want to add specific content after the last item (or before the first item), you can simply set the ListFooter or ListHeader of the control. You can put any content inside and this content will be scrolled accordingly, together with the rest of the items.

So for WP7 this would look like this:

<toolkit:LongListSelector ItemsSource="{Binding Items}">
    <toolkit:LongListSelector.ListFooter>
        <Grid>
            <Button />
        </Grid>
    </toolkit:LongListSelector.ListFooter>
</toolkit:LongListSelector>

where toolkit is xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

There are a bunch of extra features these days that can help with this scenario. One of them is the addition of additional visual states on the ScrollViewer added "HorizontalCompression" and "VerticalCompression" visual state groups. By making use of these and hooking into the CurrentStateChanging event, you can load more items as you need to.

Full details of how to implement this can be found on the Silverlight for Windows Phone Performance Team Blog.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!