Reputation: 29
SOF Tribe,
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.
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.
(I'm not allowed yet to post an image into this space...)
Please excuse the crude mockup.
This seems like a easy kill but, well, there it is.
Thanks for any reply.
Upvotes: 1
Views: 774
Reputation: 8161
In WP8.0 with LongListSelector
it was done with grouping with IsGroupingEnabled=true
.
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
.
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: How to group items in a list or grid (XAML)
Upvotes: 1