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

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

Does anyone know how to achieve this? Perhaps using a ListBox is not a good idea.

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

+2
source share
4 answers

I can’t talk about Silverlight, but the general .NET practice will be as follows:

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

This means that IEnumerable<IGrouping<string, string>>you would attach this list to your list.

XAML, , .

: IGrouping<,> IEnumerable<>, .

+7
+1
0

All Articles