C# 如何在Datagrid中对列进行排序?
我试图在Silverlight中对DatagridView中的列进行排序 这是我的课C# 如何在Datagrid中对列进行排序?,c#,silverlight,silverlight-5.0,C#,Silverlight,Silverlight 5.0,我试图在Silverlight中对DatagridView中的列进行排序 这是我的课 MyGrid.CanUserSortColumns = true; public class Row { private Dictionary<string, object> _data = new Dictionary<string, object>(); public object this[string index]
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;
}
}
我还是不能分类?我能做什么?您需要在xaml中为数据网格的每一列设置CanUserSort=“True”。这肯定会起作用。您需要在xaml中为数据网格的每一列设置CanUserSort=“True”。这肯定会有用的
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;