title: WPF listview, how to get sum of items
body: <p>I have the following listview defined(its items source is a collection of accounts with an AccountName and AccountBalance properties):</p>
  
  <pre><code>&lt;ListView x:Name="AccountList1" ItemsSource="{Binding Source={StaticResource GroupedAccounts}}" SelectedItem="{Binding SelectedAccount, Mode=TwoWay}" Margin="10" 
                IsSynchronizedWithCurrentItem="True" Background="LightGray"&gt;
              &lt;ListView.View&gt;
                  &lt;GridView&gt;
                      &lt;GridViewColumn Header="AccountName"   Width="100"&gt;
                          &lt;GridViewColumn.CellTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;TextBlock&gt;
                                  &lt;Hyperlink Command="{Binding DataContext.Navigate}" CommandParameter="{Binding}"&gt;
                                      &lt;TextBlock Text="{Binding AccountName}" /&gt;
                                  &lt;/Hyperlink&gt;
                              &lt;/TextBlock&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/GridViewColumn.CellTemplate&gt;
                      &lt;/GridViewColumn&gt;
                      &lt;GridViewColumn Header="Balance" DisplayMemberBinding="{Binding AccountBalance}"/&gt;
                  &lt;/GridView&gt;
  
              &lt;/ListView.View&gt;
  </code></pre>
  
  <p>and this collection view to group the accounts by type:</p>
  
  <pre><code>  &lt;CollectionViewSource Source="{Binding AccountList}" x:Key="GroupedAccounts" &gt;
          &lt;CollectionViewSource.GroupDescriptions&gt;
              &lt;PropertyGroupDescription PropertyName="AccountType" /&gt;
          &lt;/CollectionViewSource.GroupDescriptions&gt;
      &lt;/CollectionViewSource&gt;
  </code></pre>
  
  <p>I want to display the sum of the accounts :
  -The sum of all the accounts as the last item of the listview.
  -The sum for each group of accounts.</p>
  
  <p>Something like this:</p>
  
  <p>BankAccounts</p>
  
  <p>Account1  500$</p>
  
  <p>Account2  150$</p>
  
  <hr>
  
  <p>Total     650$</p>
  
  <p>CashAccounts</p>
  
  <p>Account3 0$</p>
  
  <p>Account4 1000$</p>
  
  <hr>
  
  <p>Total 1000$</p>
  
  <hr>
  
  <p>AllTotal 1650$</p>