Just started to master data binding in wpf, I can not figure out how to make a nested grouping of data in treeview.
There is a class
public class Track { public int year {get;set;} public string Name {get;set;} public string Category {get;set} } I want to display in treeview with grouping:
+---2010 | +---Rap | | Track 1 | | Track 2 | | | \---Rock | Track 5 | Track 6 | +---2011 +---Rap | Track 7 | Track 10 | \---Rock Track 11 In the code, I create the observable ObservableCollection<Track> items = new ObservableCollection<Track>() and fill it. Then I specify the data source for treeview: treeview.ItemsSource = items;
Further, as far as I understand, I need a HierarchicalDataTemplate. But I can not make them nested.
Now I manually create a TreeViewItem with the year, I add a child to it with a category, and to it the name of the track. I understand that this is not correct, so I want to understand how to group with the help of xaml.
HierarchicalDataTemplate. - VladD