views:

192

answers:

4

I have a ListBox to which I bound a sorted list of strings. I would like to display the list with dividers (headers) that announce the new letter - something like the 'Contacts' list on the iPhone.

Does anybody know how to achieve this goal? Perhaps using ListBox is not the right idea.

I am doing this with VS Express 2010 for Windows Phone 7.

+4  A: 

I can't speak for silverlight, but the general .NET Practice would be as follows:

var groupings = mySortedString.GroupBy(x => x.Substring(0,1));

This makes an IEnumerable<IGrouping<string, string>> you then would bind this list to your listbox.

From here you'd have to come up with the XAML to represent it how you'd like, but this would group all your items.

Note: IGrouping<,> implements IEnumerable<> so you can enumerate off it for it's items.

Aren
Thank you, Aren. I will try this shortly.
Alisa
+1  A: 

You might find some inspiration in Erik Klimczak's implementation of a jump list control.

Andréas Saudemont
+1  A: 

You can also take a look at the FluentComponents ProJumpList for Windows Phone 7:

http://www.fluentcomponents.com/Products/ProJumpList

FluentComponents