views:

345

answers:

0

Hi, I have a PagedCollectionView over an observablecollection. When a series of filters are applied to the PagedCollectionView the datagrid binding to the PagedCollectionView displays the filtered data. However, I have a textblock where I display sum of a particular property within the observablecollection(or column in the datagrid). I do this by implemeting INotfifyChanged on an object which maintains the totals in the observablecollection.

Is there a way to calculate sum of a property in a PagedCollectionView after a filter is applied. Or for that matter be able to use extensions such as Sum<>, Distinct<> etc on a PagedCollectionView for the underlysing source with the filter applied.

I tried the CollectionChanged event on the PagedCollectionView. Ther problem there is that PagedCollectionChangedevent is only fired when an item is added/removed. But when an object within the collection is changed the event does not get fired even though the object implements INotifyChanged. Second, In a scenario where we have a table with > 50000 rows, it may not be efficient to recalculate the SUM in a foreach loop of e.NewItems in the CollectionChanged event.

I was hoping there may be a better way to evaluate SUM after a filter is applied. I basically need a way to reflect the sum of a property, and also keep track of updates on the same after it is filtered.

Thanks

Vinay