Get a Jump on Navigation in Windows Phone with the LongListSelector: Listing 2.

The ListToGroupedListConverter to group list items.

public class ListToGroupedListConverter:IValueConverter
  public const string Alphabet = "abcdefghijklmnopqrstuvwxyz";
  public object Convert(object value, Type targetType, 
    object parameter, CultureInfo culture)
    if(!(value is IEnumerable))return new Group <object >[]{};
    var listOfItems = value as IEnumerable;
    var first = listOfItems.OfType <object >().FirstOrDefault();
    if (first==null) return new Group <object >[] { };
    var itemType = first.GetType();
    var keyProperty = itemType.GetProperty(parameter as string);
    var grouped = (from ing in listOfItems.OfType <object >()
      let keyValue = keyProperty.GetValue(ing,null) as string
      group ing by keyValue.ToLower()[0]
      into gd
      select gd).ToArray();
    var groups = (from letter in Alphabet
      let set = grouped.FirstOrDefault(grouping = > grouping.Key == letter)
      select new Group <object >(letter.ToString(), set)).ToArray();
      return groups;

  public object ConvertBack(object value, Type targetType, 
    object parameter, CultureInfo culture)
    return null;

About the Author

Nick Randolph runs Built to Roam, a consulting company that specializes in training, mentoring and assisting other companies build mobile applications. With a heritage in rich client applications for both the desktop and a variety of mobile platforms, Nick currently presents, writes and educates on the Windows Phone platform.

comments powered by Disqus


  • What's New in TypeScript 5.3

    Microsoft advanced TypeScript to version 5.3 with a bevy of changes affecting everything from import attributes to interactive inlay hints for types, along with multiple optimizations.

  • Finally Go Eyes On with Upcoming Visual Studio 2022 UI Refresh

    Six months ago, Microsoft teased Visual Studio 2022 developers by announcing an upcoming UI refresh, which they can now finally get their eyes on in the new v17.9 preview 1.

  • DBSCAN Data Clustering from Scratch Using C#

    Compared to other clustering techniques, DBSCAN does not require you to explicitly specify how many data clusters to use, explains Dr. James McCaffrey of Microsoft Research in this full-code, step-by-step machine language tutorial.

  • GitHub Copilot Leads Productivity Gains in New Visual Studio 2022 17.8

    In announcing Visual Studio 2022 17.8 today, Microsoft emphasized community-driven productivity gains among the new features and functionality.

  • Microsoft Ships .NET 8

    In announcing .NET 8 today, Microsoft emphasized the cloud, performance, full-stack Blazor, AI and .NET MAUI as major highlights of the latest edition of the company's free, cross-platform, open source developer platform.

Subscribe on YouTube

Upcoming Events