如何在Datagrid中对列进行排序?

时间:2013-11-01 06:20:37

标签: c# silverlight silverlight-5.0

我正在尝试在Silverlight中的My DatagridView中对列进行排序

这是我的班级

    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;

我仍然无法排序?我该怎么办?

1 个答案:

答案 0 :(得分:1)

您需要为xaml中的datagrid的每一列设置 CanUserSort =“True”。肯定会有用。