开发者

How to group data of LIstview in WPF?

开发者 https://www.devze.com 2023-02-17 15:04 出处:网络
How to group data of Listview when data are bind from SQL Database I used Collection View Source for that but it

How to group data of Listview when data are bind from SQL Database

I used Collection View Source for that but it is not working

My Code lines are mentioned below :

    CollectionViewSource viewSource = new CollectionViewSource { Source = ds };
    viewSource.GroupDescriptions.Add(new PropertyGroupDescription("RequestID"));
    ListView1.ItemsSource = viewSource.View;

but it not working properly , even data are not show in listview w开发者_JAVA百科hen Listview Item Source is bind with Collection View Source

Please help me out. Thanks a lot.


you can try the following

ICollectionView view = CollectionViewSource.GetDefaultView(ds);
view.GroupDescriptions.Add(new PropertyGroupDescription("RequestID"));
listview1.ItemsSource = view;

dont forget to set a grouping template. btw here is a related question with an complete anwser.

0

精彩评论

暂无评论...
验证码 换一张
取 消