In a UWP app, I can set a CollectionViewSource's Source to a List and it will group it right off the bat. With WPF it seems to work differently. I want to be able to group my list in code behind and just feed it the collection instead of listview doing it for me with the PropertyGroupDescription.
public class MyGroup : ObservableCollection<MyClass>
{
public int ID{ get; set; }
public MyGroup (IEnumerable<MyClass> items) : base(items)
{
ID= items.First().ID;
}
}
//other code
collectionViewSource.Source = myGroup;
Then I just bind the collectionViewSource to the ItemSource. How can I do something like this in WPF?
So the difference between UWP and WPF seems from my experience is that in UWP you pre group with ByGroup then feed a List to the CollectionViewSource. In WPF you feed the CollectionViewSource with List then it groups it itself. In UWP The datacontext for the HeaderTemplate is MyGroup. In WPF the datacontext is CollectionViewGroup. I just passed a different object through the binding and it worked.