When you trigger the OnGroupByDepartment event, it retrieves the instance of the default view of DataGrid and applies the group description to it. The grouping applies based on the property name, passed to the PropertyGroupDescription, as shared here:
cvs.GroupDescriptions.Add( new PropertyGroupDescription("Department"));
Based on that, the group style applies to the data grid. The template contains an Expander control with the name of the column to be grouped as the Header:
<Expander IsExpanded="True"> <Expander.Header> <TextBlock Text="{Binding Path=Name}" Margin="5,0,0,0"/> </Expander.Header> <Expander.Content> <ItemsPresenter /> </Expander.Content> </Expander>
You can now expand or collapse the groups and apply sorting or filtering to drill down the data. It helps to find the correct record easily.