Grouped ListView, TileView and TableΒΆ

You can create grouped ListView with GroupedList<TItem> class.

public class GroupedItem
{
   public string Name;
   public bool IsGroup = false;
}

public class GroupedItems : GroupedList<GroupedItem>
{
   /// <summary>
   /// Get group for specified item.
   /// </summary>
   /// <param name="item">Item.</param>
   /// <returns>Group for specified item.</returns>
   protected override GroupedItem GetGroup(GroupedItem item)
   {
      var name = item.Name.Length > 0 ? item.Name[0].ToString() : string.Empty;

      foreach (var key in GroupsWithItems.Keys)
      {
         if (key.Name == name)
         {
            return key;
         }
      }

      return new GroupedItem() { Name = name, IsGroup = true, };
   }
}

public class GroupedView : ListViewCustom<GroupedListViewComponent, GroupedItem>
{
   // GroupedData used to add and remove items instead of the DataSource.
   public GroupedItems GroupedData = new GroupedItems();

   bool isGroupedViewInited;

   public override void Init()
   {
      if (isGroupedViewInited)
      {
         return;
      }

      isGroupedViewInited = true;

      base.Init();

      GroupedData.GroupComparison = (x, y) => x.Name.CompareTo(y.Name);
      GroupedData.Data = DataSource;

      CanSelect = index => !DataSource[index].IsGroup;
   }
}