Windows Phone 8.1 ListView粘贴标头 [英] windows phone 8.1 ListView sticky header

查看:73
本文介绍了Windows Phone 8.1 ListView粘贴标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SOF部落

我试图在Windows Phone 8.1应用程序中理解和实现listview粘性标头概念.这是一种足够常见的行为,但是对于我来说,我找不到一个示例,可以通过我需要的交互以简单的方式实现它.

I'm trying to understand and implement the listview sticky header concept in a Windows Phone 8.1 app. It's a common enough behavior but for the life of me I can't find an example that implements it in a simple fashion with the interaction I require.

ListViewItem的顶部区域(我假设是标题)必须粘在列表视图的顶部,而ListViewItem的主体在其下方向上滚动.直到下一个ListViewItem标头顶到第一个标头,然后将其推"上.

The top band of a ListViewItem (which I'm assuming is the header) must stick to the top of the list view while the body of the ListViewItem scrolls up underneath it. Until the next ListViewItem header butts up to the first header and "pushes" it up.

https://db.tt/BvZgm3Bn

(目前还不允许我在该空间中发布图片...)

(I'm not allowed yet to post an image into this space...)

请原谅粗略的模型.

这看起来很容易杀死,但是,它就是这样.

This seems like a easy kill but, well, there it is.

感谢您的回复.

推荐答案

在带有 LongListSelector 的WP8.0中,是通过使用 IsGroupingEnabled = true 进行分组来完成的.

In WP8.0 with LongListSelector it was done with grouping with IsGroupingEnabled=true.

在带有 ListView GridView 的WP8.1中,这是通过将数据集分组到 CollectionViewSource 中完成的,但这一次您还需要定义一个 GroupStyle .然后,您的数据集将绑定到 IsSourceGrouped 设置为true的 CollectionViewSource ,而不是 IsGroupingEnabled .

In WP8.1 with ListView and GridView it is done with grouping of your dataset into a CollectionViewSource but this time you also need to define a GroupStyle. Your dataset is then bind to a CollectionViewSource which has IsSourceGrouped set to true in place of IsGroupingEnabled.

如果需要帮助(从平面列表中)对数据集进行分组,可以将其视为 List< List< List< dataitem>> ,其中外部列表​​也具有键值.如果您不熟悉分组,请搜索SO/Google以了解如何执行此操作.

If you need help grouping your dataset (from a flat list) think it as a List<List<dataitem>> where the outter list also has a key value. Search SO / Google on how to do this if you're new to grouping.

完整的示例可以在这里找到:

Full examples can be found here:

MSDN:如何对列表中的项目进行分组或网格(XAML)

这篇关于Windows Phone 8.1 ListView粘贴标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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