Export (0) Print
Expand All

CollectionViewSource.GroupDescriptions Property

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

Namespace: System.Windows.Data
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public ObservableCollection<GroupDescription> GroupDescriptions { get; }
/** @property */
public ObservableCollection<GroupDescription> get_GroupDescriptions ()

public function get GroupDescriptions () : ObservableCollection<GroupDescription>

<object>
  <object.GroupDescriptions>
    OneOrMorePropertyDescriptions
  </object.GroupDescriptions>
</object>
 OneOrMorePropertyDescriptions  One or more elements that derive from the GroupDescriptions abstract class. Typically this is a PropertyGroupDescription. 

Property Value

An ObservableCollection of GroupDescription objects that describes how the items in the collection are grouped in the view.

This property is forwarded to any collection view created from the current Source.

This example shows how to create a view of a data collection in Extensible Application Markup Language (XAML). Views allow for the functionalities of grouping, sorting, filtering, and the notion of a current item.

In the following example, the static resource named places is defined as a collection of Place objects, in which each Place object is consisted of a city name and the state. The prefix src is mapped to the namespace where the data source Places is defined. The prefix scm and dat are mapped to the System.ComponentModel and System.Windows.Data namespaces respectively.

The following example creates a view of the data collection that is sorted by the city name and grouped by the state.

<Window.Resources>

  <src:Places x:Key="places"/>

  <CollectionViewSource Source="{StaticResource places}" x:Key="cvs">
    <CollectionViewSource.SortDescriptions>
      <scm:SortDescription PropertyName="CityName"/>
    </CollectionViewSource.SortDescriptions>
    <CollectionViewSource.GroupDescriptions>
      <dat:PropertyGroupDescription PropertyName="State"/>
    </CollectionViewSource.GroupDescriptions>
  </CollectionViewSource>

</Window.Resources>

The view can then be a binding source, as in the following example:

<ListBox ItemsSource="{Binding Source={StaticResource cvs}}"
         DisplayMemberPath="CityName" Name="lb">
  <ListBox.GroupStyle>
    <x:Static Member="GroupStyle.Default"/>
  </ListBox.GroupStyle>
</ListBox>

To see the entire example, please see Collection View Source Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft