2

I'm using c# and WPF. I have a WPF DataGrid that needs to be binded to several data sources. What I did is create for each data source the following code:

var listCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(myObservableCollection);
var collection = new CollectionContainer { Collection = listCollectionView };
myCompositeCollection.Add(collection);

'myCompositeCollection' is my items source for the grid. I can't create one list because the data sources come from different entities and I don't want to handle the add/delete/update/reset of each observable collection.

However each different data source should be in a different group in the grid. How do I add a grouping (even a custom implementation) instead of the regular 'GroupDescriptions' of the ICollectionView that doesn't work on CompositeCollections?

Thanks.

Maya S
  • 127
  • 1
  • 9
  • Nobody? Maya did you find any workaround? – Raúl Nuño Mar 23 '18 at 20:47
  • The only workaround I found is that I added to the collection a 'separator' item that it's style will look like an expander. Whenever it was clicked I removed from the CompositeCollection all objects that belonged to the groupe and re added them if it was clicked again. For each change in one of the objects I recalculated to which group it belonged and changed the index accordingly. Very heavy, but didn't find another option. – Maya S Apr 09 '18 at 08:54

0 Answers0