0

So I have a Datagrid fed via a ViewSource. I've enabled grouping on it and display a title and count in the group header. This all works but I would like to also display a sum of an item in the group header.

I know I can use a converter to sum the items I want via: WPF DataGrid Grouping with sums and other fields

But isn't there a built in way to do this since it's already summing to get the count?

Community
  • 1
  • 1
Kelly
  • 6,992
  • 12
  • 59
  • 76

1 Answers1

0

In the converter example you linked to, a custom data type is used. The GroupsToTotalConverter in the example uses the Amount property of that custom data type to calculate the totals.

Therein lies the rub, as nothing built-in allows sums made from custom data type properties. Something somewhere has to know which field/property/method to access, and nothing built-in could, since a custom data type is used.

Converters are intended for that purpose, though, and is a built-in way to do bridge xaml and data from custom data types

So in short: Converters are the built-in way of doing what you need.

KVarmark
  • 226
  • 3
  • 4