0

I thought that this would be simple, maybe it is.

I want to know the number of rows in a CollectionViewSource after filtering has been applied (not the total number of rows in the source).

Is there a property for this? Do I have to calculate this during the Filter event?

Intensivist
  • 767
  • 2
  • 7
  • 19

1 Answers1

1

Found it

"You could also do _viewSource.View.Cast<object>().Count() for the filtered list and _viewSource.View.SourceCollection.Cast<object>().Count() for the original." -@rhyek

Community
  • 1
  • 1
MichaelN
  • 156
  • 8
  • But I couldn't bind to that from XAML. I want a label to be bound to that value – Intensivist Jul 31 '15 at 15:39
  • Looks like you need to make a Dependency Property, which I'm not very good at to be honest. – MichaelN Jul 31 '15 at 15:50
  • [Maybe this.](http://stackoverflow.com/questions/4609953/how-can-i-bind-datagrid-row-count-after-a-collectionview-filter-is-applied) Bind to the Object that displays you CollectionViewSouce with the Items.Count Property instead of ItemsSouce.Count. (Assuming that's what you're doing) – MichaelN Jul 31 '15 at 15:55
  • I went with this solution: _viewSource.View.Cast().Count(). I run it after each load or filtering action. Assign the value to something in my viewmodel to which I bind. Too bad that a CollectionViewSource doesn't have a Count property that you can easily bind to. – Intensivist Jul 31 '15 at 18:07