GroupDescriptions Property
See Also  Example
Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DataGridCollectionViewSource Class : GroupDescriptions Property


Gets or sets a collection GroupDescription objects that describe how the items contained in the collection are grouped in the view.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property GroupDescriptions As ObservableCollection(Of GroupDescription)
Visual Basic (Usage)Copy Code
Dim instance As DataGridCollectionViewSource
Dim value As ObservableCollection(Of GroupDescription)
 
value = instance.GroupDescriptions
C# 
public ObservableCollection<GroupDescription> GroupDescriptions {get;}

Return Value

An Observable collection of GroupDescription objects that describe how the items contained in the collection are grouped in the view.

Example

All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
The following example demonstrates how to group the data items by the ShipCountry and ShipCity columns.
XAMLCopy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> 
  <Grid.Resources> 
    <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" 
                                     Source="{Binding Source={x:Static Application.Current},  
                                                      Path=Orders}">         
      <xcdg:DataGridCollectionViewSource.GroupDescriptions>           
        <xcdg:DataGridGroupDescription PropertyName="ShipCountry"/> 
        <xcdg:DataGridGroupDescription PropertyName="ShipCity"/> 
      </xcdg:DataGridCollectionViewSource.GroupDescriptions> 
    </xcdg:DataGridCollectionViewSource> 
  </Grid.Resources> 
     
  <xcdg:DataGridControl x:Name="OrdersGrid" 
                        ItemsSource="{Binding Source={StaticResource cvs_orders}}">       
  </xcdg:DataGridControl> 
</Grid>
The following example demonstrates how to bind the grid to the Orders table and prevent columns from being sorted and reordered and groups from being created or removed. By default, the ShipCountry and ShipCity columns will be sorted, grouped, and fixed.
XAMLCopy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" 
      xmlns:d="clr-namespace:System.Windows.Data;assembly=PresentationFramework" 
      xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"> 
  <Grid.Resources> 
    <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" 
                                     Source="{Binding Source={x:Static Application.Current},  
                                                      Path=Orders}"> 
      <xcdg:DataGridCollectionViewSource.SortDescriptions> 
        <scm:SortDescription PropertyName="ShipCountry" Direction="Ascending"/> 
        <scm:SortDescription PropertyName="ShipCity" Direction="Ascending"/> 
      </xcdg:DataGridCollectionViewSource.SortDescriptions> 
      <xcdg:DataGridCollectionViewSource.GroupDescriptions> 
        <xcdg:DataGridGroupDescription PropertyName="ShipCountry"/> 
        <xcdg:DataGridGroupDescription PropertyName="ShipCity"/> 
      </xcdg:DataGridCollectionViewSource.GroupDescriptions> 
    </xcdg:DataGridCollectionViewSource> 
  </Grid.Resources> 
  <xcdg:DataGridControl x:Name="OrdersGrid" 
                        ItemsSource="{Binding Source={StaticResource cvs_orders}}">         
    <xcdg:DataGridControl.Columns> 
      <xcdg:Column FieldName="ShipCountry" VisiblePosition="0"/> 
      <xcdg:Column FieldName="ShipCity" VisiblePosition="1"/> 
    </xcdg:DataGridControl.Columns> 
    <xcdg:DataGridControl.View> 
      <xcdg:TableView FixedColumnCount="2"> 
        <xcdg:TableView.FixedHeaders> 
          <xcdg:ClearHeadersFooters/> 
          <DataTemplate> 
            <xcdg:GroupByControl AllowSort="False" AllowGroupingModification="False"/> 
          </DataTemplate> 
          <DataTemplate> 
            <xcdg:ColumnManagerRow AllowSort="False" AllowColumnReorder="False"/> 
          </DataTemplate> 
        </xcdg:TableView.FixedHeaders> 
      </xcdg:TableView> 
    </xcdg:DataGridControl.View> 
  </xcdg:DataGridControl> 
</Grid>

Remarks

Although standard PropertyGroupDescription objects are supported, for performance reasons, it is recommended to use DataGridGroupDescription objects instead.

The value of this property is forwarded to any collection view created from the current Source.

Requirements

Supported Frameworks: Microsoft .NET Framework version 3.0

See Also