Bent Rasmussen
Bent Rasmussen

Reputation: 5702

ObservableCollection + ICollectionView = ObservableCollectionView?

I have a View Model that exposes an ObservableCollection. Now I want to add grouping and therefore want to use a View class, like e.g. the ListCollectionView. But that is not a generic type. Also, if I construct a ListCollectionView from an ObservableCollection, then it is not updated when the ObservableCollection is.

Did someone implement an ObservableCollection-backed View-collection somewhere?

If not, is it possible to achieve this dynamism somehow by using XAML?

Upvotes: 1

Views: 2734

Answers (1)

Thomas Levesque
Thomas Levesque

Reputation: 292605

You don't need a specific implementation ; a CollectionView is just a view of a collection. You can get the default CollectionView for a collection using CollectionViewSource.GetDefaultView:

ObservableCollection<Something> collection = ...
ICollectionView view = CollectionViewSource.GetDefaultView(collection);

Upvotes: 2

Related Questions