This documentation is archived and is not being maintained.

SortDescription.PropertyName Property

Gets or sets the property name being used as the sorting criteria.

Namespace: System.ComponentModel
Assembly: WindowsBase (in windowsbase.dll)

public string PropertyName { get; set; }
/** @property */
public String get_PropertyName ()

/** @property */
public void set_PropertyName (String value)

public function get PropertyName () : String

public function set PropertyName (value : String)

<object PropertyName="string" .../>

Property Value

The default value is null.

This property should be a public property of the items in the underlying collection.

The string is interpreted by the particular ICollectionView object involved in the sorting. BindingListCollectionView only supports simple column names. ListCollectionView supports general property paths and XPath for XML data. Therefore, when the view is a ListCollectionView object, you can sort XML nodes in an XmlDataProvider based on an attribute of those nodes. For example, if the attribute name is Cost, you would specify "@Cost" for the PropertyName in the SortDescription.

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.


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

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


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

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

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