Skip to main content

Lesson 3: Sort Data

The DXCollectionView allows you to sort its items. To do this:

  1. Create a SortDescription object and specify its FieldName and SortOrder properties.
  2. Add this object to the DXCollectionView.SortDescriptions collection.

You can sort list items by multiple data fields. To do this, create a SortDescription object for each field that should be sorted. The order in which you add these objects to the DXCollectionView.SortDescriptions collection defines the sorting sequence in a DXCollectionView.

For example, open the solution created in Lesson 2 and sort contacts in the descending order:

<dxcv:DXCollectionView ItemsSource="{Binding Data}">
    <!-- Define ItemTemplate here.-->

    <!--Sort items.-->
    <dxcv:DXCollectionView.SortDescriptions>
        <dxcv:SortDescription FieldName="Name" SortOrder="Descending"/>
    </dxcv:DXCollectionView.SortDescriptions>
</dxcv:DXCollectionView>

Before

After

Collection View - Item Template

Collection View - Sort Data

The next lesson explains how to group list items.