How would I display a running total for a particular column of each record that is displayed in a DataGrid? I'd like to keep the computation logic in the view model.
Desired Output:
Value | Running Total 25 25 10 35 -2 33
Thank you,
Ben
Edit: Keep in mind that when a user-triggered DataGrid sort occurs, the running totals must be recalculated because the record display order has changed.
I'd really like to put the logic for this in the view model, not in WPF code (e.g. not using an IValueConverter).
It is only idea: actually, DataGrid uses ICollectionView interface ( http://msdn.microsoft.com/en-us/library/system.componentmodel.icollectionview.aspx) to implement sorting (as described in http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid(VS.95).aspx at Grouping, Sorting, and Filtering section.
So, you can create class that implements ICollectionView interface, and observe sorting with corresponding updating of running total.