user911671
user911671

Reputation:

How to Sort Columns in Datagrid?

I am trying to sort column in My DatagridView in Silverlight

This is My class

    MyGrid.CanUserSortColumns = true;
    public class Row
    {
        private Dictionary<string, object> _data = new Dictionary<string, object>();
        public object this[string index]
        {
            get { return _data[index]; }
            set { _data[index] = value; }
        }
        public Dictionary<string, object> GetData()
        {
           return _data;
        }
   }

   ObservableCollection<Row> RowList = new ObservableCollection<Row>();

   foreach (string _Row in _DATA)
   {
       Row row = new Row();

       //some Data to add

       RowList.Add(row);
   }
}

PagedCollectionView RowListView = new PagedCollectionView(RowList);
this.MyGrid.ItemsSource = RowListView;

Still I cant Sort? What can I do ?

Upvotes: 1

Views: 105

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222532

You need to set the CanUserSort="True" for each column of your datagrid in xaml. Definitely this will work.

Upvotes: 1

Related Questions