WPF 针对数据源某个属性进行排序

原文: WPF 针对数据源某个属性进行排序

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wanlong360599336/article/details/39368165



ICollectionView view = CollectionViewSource.GetDefaultView(dataSource);//dataSource为数据源

            
view.SortDescriptions.Clear();
            
if (isAcsending)
            
{
                
isAcsending = false;
                
view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));//升序
            

            
else
            
{
                
isAcsending = true;


view.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Descending));//降序
            
}

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/10253930.html
今日推荐