views:

67

answers:

1

We have multiple filters based on the same collection. i.e. we are displaying the same collection in a variety of ways. What i would like to be able to do is ask all of the CollectionViews to refresh when a property changes (as the collection view will only refilter if items get added/removed from the collection). Is there a way to find all the collectionViews associated with a given collection. Is there a two way link between the collection view and the collection, or a way to determine this link.

P.S. I dont think the answer is

ICollectionView coll = CollectionViewSource.GetDefaultView(Collection);

as this will give me the default view for the collection, not all of the ICollectionViews asscoiated with the Collection.

A: 

If your collection is an ObservableCollection, you can do a ResettableObservableCollection.

public class ResettableObservablecollection<T>: ObservableCollection<T>
{
   //copy desired ctors

   public void ForceReset()
   {
       OnCollectionChanged(new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Reset));
   }
}

The ICollectionView that gets generated will be watching for that and refresh itself.

Tom
that makes sense, i wonder what performance impact it would have if the collection view was bound to a grid with a thousand entries or so. I'll try this out Monday.
Aran Mulholland