title: Summing class attributes in XAML ListView control
body: <p>I'm pretty new to C# so I've been struggling with this for so long I dont know what i should do...</p>
  <p>I want to sum 2 (or more) values from my class (<code>sum</code> + <code>interestRate_1</code>) among other calculations and display the results in my respective <code>ListView</code> columns for every class instance I create to my <code>ObservableCollections</code> -list.
  The <code>ListView</code> itself is bound by <code>ItemSource</code> and contains all the created <code>Cust</code> -objects im trying to perform calculations on.</p>
  <p>I'm totally new to XAML so i dont know how it works. People tell me to use a converter but I'm not sure what it implies...</p>
  <p><strong>Here's what I've tried:</strong></p>
  <p>XAML declaration:</p>
  <pre><code>&lt;Window x:Class=&quot;MyProject.MainWindow&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
      xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
      xmlns:local=&quot;clr-namespace:MyProject&quot;
      mc:Ignorable=&quot;d&quot;
      Title=&quot;MyProject (beta)&quot; Height=&quot;450&quot; Width=&quot;1000&quot; MinWidth=&quot;1000&quot; MinHeight=&quot;450&quot; ResizeMode=&quot;CanResize&quot;&gt;
  </code></pre>
  <p>XAML <code>ListView</code>:</p>
  <pre><code>&lt;ListView x:Name=&quot;ListTest&quot; Margin=&quot;10,150,10,66&quot; Background=&quot;#FF0077B6&quot; Foreground=&quot;White&quot; MouseDoubleClick=&quot;ListTest_MouseDoubleClick&quot; SelectionChanged=&quot;ListTest_SelectionChanged&quot; IsSynchronizedWithCurrentItem=&quot;True&quot; ItemsSource=&quot;{Binding CustList}&quot; Grid.RowSpan=&quot;2&quot;&gt;
      &lt;ListView.Effect&gt;
          &lt;DropShadowEffect/&gt;
      &lt;/ListView.Effect&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
  
              &lt;GridViewColumn Header=&quot;Name&quot; Width=&quot;136&quot; DisplayMemberBinding=&quot;{Binding Name}&quot;/&gt;
              &lt;GridViewColumn Header=&quot;Amount (€)&quot; Width=&quot;80&quot; DisplayMemberBinding=&quot;{Binding Sum}&quot;/&gt;
              &lt;GridViewColumn Header=&quot;Amount With Interest (€)&quot;  Width=&quot;80&quot;&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource AddConverter}&quot;&gt;
                      &lt;Binding Path=&quot;Sum&quot;/&gt;
                      &lt;Binding Path=&quot;interestRate_1&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/GridViewColumn&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  <p>C# Converter + List of <code>Cust</code> -objects:</p>
  <pre><code>namespace MyProject
  {
      public class AddConverter : IMultiValueConverter
      {
          public object Convert(object[] values, Type tagetType, object parameter, CultureInfo culture)
          {
  
              var decimalValues = values.Cast&lt;decimal&gt;().ToArray();
              var resultSum = decimalValues.Sum().ToString();
              return resultSum;
  
          }
  
          public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
          {
              throw new NotImplementedException();
          }
      }
  
      public partial class MainWindow : Window
      {
  
          public ObservableCollection&lt;Cust&gt; CustList = new ObservableCollection&lt;Cust&gt;();
  
          public MainWindow()
          {
              InitializeComponent();
  
              ListTest.ItemsSource = CustList;
              
          }
  
  //...
  </code></pre>
  <p>Relevant Class attributes / Properties:</p>
  <pre><code>public class Cust
  {
      public Name {get; set;}
      private decimal sum;
      public decimal Sum
      {
  
          get { return sum; }
          set { sum = value; }
  
      }
  
      public decimal interestRate_1 { get; set; } = 3.0M;
      public decimal interestRate_2 { get; set; } = 5.0M;
  
  // ...
  </code></pre>
  <p>Wha i know is that XAML cannot find the converter from the .cs file and that I use <code>Header</code> twice in the column I'm trying to convert (which I dont understand). Am I totally lost here?</p>