Is it possible to have a listbox (or another control that has a SelectedItem) bound to a ICollectionView, displaying items like this :
- Item1Name
- Item2Name
- ParentName1
- Item3Name
- Item4Name
- ParentName2
- Item5Name
- Item6Name
The class used as a source for the CollectionViewSource’s view :
public class Item
{
public string Name { get; set; }
public string Parent { get; set; }
}
Item1 and Item2 have ParentName property set to null, Item3 and Item4 have “ParentName1” as ParentName property, and so on.
I really like the listbox approach because only items can be selected, groups are not selectable. But I may be going the wrong path.
Finally I implemented a style selector for setting group style if group is null :
and group styles with templates :