We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to sort your binded collection of ViewModel?

Platform: WPF |
Control: SfDataGrid |
Published Date: August 6, 2014 |
Last Revised Date: September 30, 2016 |
.NET Framework: 4.5 |
Product Version: 12.1.0.43
Tags: sorting

By default, DataGrid will not sort the underlying collection when displayed in the grid. When you sort a column, internally datagrid will maintain the underlying collection and does a sort that reflects only in view. So, if you want to sort the underlying collection of view model, you can apply sorting by using SortColumnChanged event.

C#

 

Note: In Silverlight, the following code sample can be used to get the current sort column value.

C#

 

Here, the underlying collection of SfDataGrid is taken by GetValue. If sortColumn.Direction is ListSortDirection.Ascending the sorting is applied for that collection in ascending direction, that is based on SortDescriptions column, otherwise it will be sorted in descending direction. OrderSource method is used to get the column value.

Sample Links:

WPF

WRT

SilverLight

UWP

 

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon