0

I need a sorting, grouping and filtering behavior of a CollectionView also with LiveShaping properties, but every .NET implementation has a Dispatcher connected to it.

Is there any implementation of the ICollectionView without a dispatcher?

msedi
  • 1,437
  • 15
  • 25
  • What's the problem with the dispatcher? What are you trying to accomplish? – mm8 Apr 11 '17 at 08:53
  • I need some lightweight object that can even be used in Console applications. To my knowledge if no System.Windows.Application has started, no Dispatcher is available. – msedi Apr 11 '17 at 09:25
  • It makes no sense to use any of the built-in implementations of the ICollectionView in a console application. I doubt it makes any sense to use the ICollectionView at all. Again: What are you trying to accomplish? – mm8 Apr 11 '17 at 09:27
  • I'm trying to get the grouping, filtering and sorting capabilities of the CollectionView. – msedi Apr 11 '17 at 09:28
  • Why would you use an Collection view in a console application? You might as well group, filter and sort the source collection directly. – mm8 Apr 11 '17 at 09:29
  • the source is a set of CompositeCollections where some other task/threads are changing the content. Of course I can hook into the change notifications of each CompositeCollection, but there are many different observers that need to group it into different categories. Therefore I cannot group it beforehand, but need to do it in the related subareas. Hooking into change notifications is doable, but since the collectionview already has this I see no reason to reimplement it. – msedi Apr 11 '17 at 09:36

2 Answers2

1

From MSDN:

Remarks:

The interface is implemented by the CollectionView class, which is the base class for BindingListCollectionView, ListCollectionView, and ItemCollection.

CollectionView derives from System.Windows.Threading.DispatcherObject, so this class and all derived will always have Dispatcher property, because Dispatcher property is not virtual, abstract or override, other way you could mark it as sealed and use a derived class without Dispatcher property.

Other remark for CollectionView:

Remarks:

You should not create objects of this class in your code. To create a collection view for a collection that only implements IEnumerable, create a CollectionViewSource object, add your collection to the Source property, and get the collection view from the View property.

It is not a solution of your problem, but an answer on your question.

Rekshino
  • 6,954
  • 2
  • 19
  • 44
1

Is there any implementation of the ICollectionView without a dispatcher?

No, there isn't. The only class that implements this interface in the .NET Framework is the CollectionView class and it is a DispatcherObject.

So you will have to provide your own implementation or solve your issue in a different way.

mm8
  • 163,881
  • 10
  • 57
  • 88