Reputation: 31
I am looking for some help in dynamically creating groups in a WPF listview. In WinForm I would do the following to create the group:
ListViewGroup Group1 = new ListViewGroup();
myListView.Groups.Add(Group1);
ListViewGroup Group2 = new ListViewGroup();
myListView.Groups.Add(Group2);
and this would create the groups. I can then do the following to add items to the groups:
myListView.Items.Add(new ListViewItem("Some String1", Group1))
myListView.Items.Add(new ListViewItem("Some String2", Group2))
In WPF I have searched but could not find a way to do this. Is it possible? I have already created the list view using the following:
<ListView Name="myWPFListView" Grid.Column="1" Margin="9,61,0,20" Grid.Row="0" HorizontalAlignment="Left" Width="252" >
<ListView.View>
<GridView>
<GridViewColumn Header="myHeader" Width="252"/>
</GridView>
</ListView.View>
</ListView>
from here I don't know how to proceed as I would like to create the groups from another class.
Thanks for the help.
Upvotes: 0
Views: 659
Reputation: 1343
You need to use data binding and data template to Bind your data this will help you.
Upvotes: 1