Articles in this section
Category / Section

How to create a grouped ListView in .NET MAUI (SfListView) ?

4 mins read

The .NET MAUI ListView (SfListView) supports grouping items based on custom logic using the GroupDescriptor. This guide demonstrates how to implement grouping based on the first character of each item's name.


Key Properties of GroupDescriptor

The GroupDescriptor object holds the following properties: 

  • PropertyName: Identifies the name of the property to group by.
  • KeySelector : Function defining custom logic to determine the group key.
  • Comparer : Optional custom comparer for sorting grouped items.

C#

Below is an example of creating a grouped ListView based on the first character of the contact name.

  public class Behavior : Behavior<Syncfusion.Maui.ListView.SfListView>
  {
        private Syncfusion.Maui.ListView.SfListView ListView;
        protected override void OnAttachedTo(Syncfusion.Maui.ListView.SfListView bindable)
        {
            ListView = bindable;
            ListView.DataSource.GroupDescriptors.Add(new GroupDescriptor()
            {
                PropertyName = "ContactName",
                KeySelector = (object obj1) =>
                {
                    var item = (obj1 as ListViewContactInfo);
                    return item.ContactName[0].ToString();
                },
            });
            base.OnAttachedTo(bindable);
        }
 
        protected override void OnDetachingFrom(Syncfusion.Maui.ListView.SfListView bindable)
        {
            ListView = null;
            base.OnDetachingFrom(bindable);
        }
}

Output


Create grouped ListView in .NET MAUI


Download the complete sample on GitHub

Conclusion

I hope you enjoyed learning how to create a grouped ListView in .NET MAUI.

You can refer to our .NET MAUI ListView feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. Explore our .NET MAUI ListView example to understand how to create and manipulate data.

For current customers, check out our components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our other controls.
Please let us know in the comments section if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied