All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
1.1
The page you are viewing does not exist in version 1.1. This link will take you to the root page.

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.