# Property Group Descriptor for .NET MAUI DataGrid

The `PropertyGroupDescriptor` is used to group the data in a [.NET MAUI DataGrid](https://www.telerik.com/maui-ui/documentation/controls/datagrid/overview) by property from the class that defines your objects.

To use the `PropertyGroupDescriptor`, you have to set its `PropertyName` (`string`) property, which gets or sets the name of the property that is used to retrieve the key by which to group.

To specify the content that is used to represent the group descriptor visually within the grouping panel, set the `DisplayContent` (`object`) property.

> note You can sort the groups in ascending or descending order by using the `SortOrder` property.

Let's, for example, have the following business object:

```C#
public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    public string Department { get; set; }
}
```

Add a sample `ViewModel` class with a collection of `Person` objects:

```C#
public class ViewModel
{      
    public ViewModel()
    {
        this.People = new ObservableCollection<Person>()
        {
            new Person { Name = "Kiko", Age = 23, Department = "Production" },
            new Person { Name = "Jerry", Age = 23, Department = "Accounting and Finance"},
            new Person { Name = "Ethan", Age = 51, Department = "Marketing" },
            new Person { Name = "Isabella", Age = 25, Department = "Marketing" },
            new Person { Name = "Joshua", Age = 45, Department = "Production" },
            new Person { Name = "Logan", Age = 26, Department = "Production"},
            new Person { Name = "Aaron", Age = 32, Department = "Production" },
            new Person { Name = "Elena", Age = 37, Department = "Accounting and Finance"},
            new Person { Name = "Ross", Age = 30, Department = "Marketing" },
        };
    }

    public ObservableCollection<Person> People { get; set; }
}
```

Define the `DataGrid`:

```XAML
<telerik:RadDataGrid x:Name="dataGrid"
                     ItemsSource="{Binding People}" />
```

All that is left is to set is the `ViewModel` as `BindingContext` of the page:

```C#
this.BindingContext = new ViewModel();
```

Apply the `PropertyGroupDescriptor`:

```C#
this.dataGrid.GroupDescriptors.Add(new Telerik.Maui.Controls.Data.PropertyGroupDescriptor()
{
    PropertyName="Department"
});
```

Here is how the DataGrid looks when it's grouped:

![.NET MAUI DataGrid grouped with a PropertyGroupDescriptor using a model property](https://www.telerik.com/maui-ui/documentation/assets/cd6f753aef455483bcf1ac0b759fc845/datagrid-property-group-descriptor.png)

## See Also

* [Grouping UI](https://www.telerik.com/maui-ui/documentation/controls/datagrid/grouping/grouping-ui)
* [Group Header Template](https://www.telerik.com/maui-ui/documentation/controls/datagrid/grouping/group-header-template)
