views:

51

answers:

2

I have a collection that contains all the items that I want to keep track of. I want to display 3 different grids, and in each one I want to display a different filtered version of the items. Is there a way to bind to a filtered version of the main collection without having to maintain 3 separate collections to bind to?

+1  A: 

In order to use databinding, you must use the entire collection. I suggest you split the collection, and bind to each.

Gabriel McAdams
I ended up going this route.
Shane Fulmer
A: 

You can create multiple CollectionView instances, each of which gives a different view of the collection. Note that you'll need to instantiate an appropriate derived type, such as ListCollectionView or CollectionViewSource.


Sorry, I just realized you're in WinForms; the above is a WPF class. You can probably use it anyway if you're willing to include a reference to PresentationFramework (even if you're not using WPF for your application.)

Dan Bryant
Are there any issues with adding a reference to PresentationFramework from Winforms?
Shane Fulmer
I haven't tried using CollectionViews in particular from WinForms, but I've linked to it for hosting WPF Controls inside an ElementHost WinForms Control with no problems.
Dan Bryant