WP7 ListBox Grouping

2020-05-29 02:09发布

问题:

Is there any in-built grouping for ListBoxes or another UI control? I would like to have a list but have some form of grouping or sections applied to the list. As shown below:

heading one
     list item one
     list item two
heading two
     list item one
     list item two
     list item three
     list item four

Is there anything available for such purpose without building something from scratch? I don't wish to mix a match multiple ListBoxes, rather I would prefer a solution where this was handled at the data binding level.

回答1:

You want to look at the "Long List Selector" in the Silverlight for Windows Phone Toolkit

Its a control that looks+behaves just like the grouping behavior in contacts/etc on the phone.



回答2:

LongListSelector comes to mind.

Using LongListSelector without LINQ - Andy Pennell's Blog

WP7 LongListSelector in depth | Part1: Visual structure and API | WindowsPhoneGeek

WP7 LongListSelector in depth | Part2: Data binding scenarios | WindowsPhoneGeek

Alternatively, you could look into applying either of these grouping implementations to the phone's listbox.

Confessions of a ListBox groupie [Using IValueConverter to create a grouped list of items simply and flexibly] - Delay's Blog

How to group items in a list by their first letter in Silverlight? - Stack Overflow



回答3:

Have you considered putting the different lists in different items in a pivot?