title: DataGrid Calculated column does not show any data
body: <p>Let's have an example to understand my problem clearly :</p>
  
  <p>I have three TextBox Controls as below :</p>
  
  <pre><code>&lt;TextBox x:Name="Quantity" /&gt;
  &lt;TextBox x:Name="Rate" /&gt;
  &lt;TextBox x:Name="Amount" /&gt;
  </code></pre>
  
  <p>So, I want to calculate Amount when Quantity or Rate Changes.
  <strong>Amount = Quantity * Rate</strong></p>
  
  <p>Similarly I want to change Rate if user intends to change Amount. So, formula for Rate will be
  <strong>Rate = Amount / Quantity</strong></p>
  
  <p><strong>Actual Problem:</strong></p>
  
  <p>I have a DataGrid with the three Columns :</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding OpeningBalances}"&gt;
  
      &lt;DataGrid.Columns&gt;
  
          &lt;DataGridTemplateColumn Header="Quantity" &gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBlock Text="{Binding Quantity}"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBox Text="{Binding Quantity}" Loaded="TextBox_Loaded"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
  
          &lt;DataGridTemplateColumn Header="Rate" &gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBlock Text="{Binding Rate}"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBox Text="{Binding Rate}" Loaded="TextBox_Loaded"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
  
          &lt;DataGridTemplateColumn Header="Amount" &gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBlock&gt;
                          &lt;TextBlock.Text&gt;
                              &lt;MultiBinding Converter="{StaticResource amountFromQuantityAndRateConverter}"&gt;
                                  &lt;Binding Path="Quantity" /&gt;
                                  &lt;Binding Path="Rate" /&gt;
                              &lt;/MultiBinding&gt;
                          &lt;/TextBlock.Text&gt;
                      &lt;/TextBlock&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;TextBox Loaded="TextBox_Loaded"&gt;
                          &lt;TextBox.Text&gt;
                              &lt;MultiBinding Converter="{StaticResource amountFromQuantityAndRateConverter}"&gt;
                                  &lt;Binding Path="Quantity" /&gt;
                                  &lt;Binding Path="Rate" /&gt;
                              &lt;/MultiBinding&gt;
                          &lt;/TextBox.Text&gt;
                      &lt;/TextBox&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
  
      &lt;/DataGrid.Columns&gt;
  
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p><em>Property declaration in ViewModel :</em></p>
  
  <pre><code>public MainWindowViewModel()
  {
      OpeningBalances = new ObservableCollection&lt;ItemOpeningBalanceRow&gt;();
  }
  
  private ObservableCollection&lt;ItemOpeningBalanceRow&gt; _openingBalances;
  public ObservableCollection&lt;ItemOpeningBalanceRow&gt; OpeningBalances
  {
      get
      {
          return _openingBalances;
      }
      set
      {
          _openingBalances = value;
          OnPropertyChanged("OpeningBalances");
      }
  }
  </code></pre>
  
  <p><em>ItemOpeningBalnceRow.cs :</em></p>
  
  <pre><code>public class ItemOpeningBalanceRow 
  {
      public double Quantity { get; set; }
      public double Rate { get; set; }
      public double Amount { get; set; }
  }
  </code></pre>
  
  <p>Converter - <em>AmountFromQuantityAndRateConverter.cs</em></p>
  
  <pre><code>public class AmountFromQuantityAndRateConverter : IMultiValueConverter
  {
      public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          int _quantity = 0;
          int _rate = 0;
  
          if (int.TryParse(values[0].ToString(), out _quantity) &amp;&amp; int.TryParse(values[1].ToString(), out _rate))
          {
              return _quantity * _rate;
          }
  
          return 0;
      }
  
      public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>I have used above mentioned Multi Value converter but still Amount column always remains null. I mean it does not display any data.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>The answer given by @sky-dev is the best possible answer and is working fine. But I would like to get the same approach using converters. </p>
  
  <p><strong>What I have tried?:</strong></p>
  
  <p>I have created two converters as follows:</p>
  
  <p>RateFromAmountAndQuantityConverter.cs </p>
  
  <pre><code>public class RateFromAmountAndQuantityConverter : IMultiValueConverter
  {
      public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          int _quantity = 0;
          int _amount = 0;
          int _rate = 0;
  
          if (int.TryParse(values[0].ToString(), out _quantity) &amp;&amp; int.TryParse(values[1].ToString(), out _amount) &amp;&amp; int.TryParse(values[2].ToString(), out _rate))
          {
              if (_quantity != 0 &amp;&amp; _amount != 0)
              {
                  if (_rate == _amount / _quantity)
                      return _rate.ToString();
                  else
                      return (_amount / _quantity).ToString();
              }
          }
  
          return "0";
      }
  
      public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>And other is AmountFromQuantityAndRateConverter.cs</p>
  
  <pre><code>public class AmountFromQuantityAndRateConverter : IMultiValueConverter
  {
      public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          int _quantity = 0;
          int _rate = 0;
          int _amount = 0;
  
          if (int.TryParse(values[0].ToString(), out _quantity) &amp;&amp; int.TryParse(values[1].ToString(), out _rate) &amp;&amp; int.TryParse(values[2].ToString(), out _amount))
          {
              if (_rate != 0)
              {
                  if (_amount == _quantity * _rate)
                      return _amount.ToString();
                  else
                      return (_quantity * _rate).ToString();
              }
          }
  
          return "0";
      }
  
      public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>I call them as follows:</p>
  
  <pre><code>&lt;DataGridTemplateColumn Header="Quantity" &gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBlock Text="{Binding Quantity, UpdateSourceTrigger=PropertyChanged}"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBox Text="{Binding Quantity, UpdateSourceTrigger=PropertyChanged}" Loaded="TextBox_Loaded"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  &lt;/DataGridTemplateColumn&gt;
  
  &lt;DataGridTemplateColumn Header="Rate" &gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBlock&gt;
                  &lt;TextBlock.Text&gt;
                      &lt;MultiBinding Converter="{StaticResource rateFromAmountAndQuantityConverter}"&gt;
                          &lt;Binding Path="Quantity" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Amount" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Rate" UpdateSourceTrigger="PropertyChanged" /&gt;
                      &lt;/MultiBinding&gt;
                  &lt;/TextBlock.Text&gt;
              &lt;/TextBlock&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBox Loaded="TextBox_Loaded"&gt;
                  &lt;TextBox.Text&gt;
                      &lt;MultiBinding Converter="{StaticResource rateFromAmountAndQuantityConverter}" &gt;
                          &lt;Binding Path="Quantity" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Amount" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Rate" UpdateSourceTrigger="PropertyChanged" /&gt;
                      &lt;/MultiBinding&gt;
                  &lt;/TextBox.Text&gt;
              &lt;/TextBox&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  &lt;/DataGridTemplateColumn&gt;
  
  &lt;DataGridTemplateColumn Header="Amount" &gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBlock&gt;
                  &lt;TextBlock.Text&gt;
                      &lt;MultiBinding Converter="{StaticResource amountFromQuantityAndRateConverter}"&gt;
                          &lt;Binding Path="Quantity" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Rate" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Amount" UpdateSourceTrigger="PropertyChanged" /&gt;
                      &lt;/MultiBinding&gt;
                  &lt;/TextBlock.Text&gt;
              &lt;/TextBlock&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBox Loaded="TextBox_Loaded"&gt;
                  &lt;TextBox.Text&gt;
                      &lt;MultiBinding Converter="{StaticResource amountFromQuantityAndRateConverter}"&gt;
                          &lt;Binding Path="Quantity" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Rate" UpdateSourceTrigger="PropertyChanged"/&gt;
                          &lt;Binding Path="Amount" UpdateSourceTrigger="PropertyChanged" /&gt;
                      &lt;/MultiBinding&gt;
                  &lt;/TextBox.Text&gt;
              &lt;/TextBox&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  &lt;/DataGridTemplateColumn&gt;
  </code></pre>
  
  <p><strong>Problems using above two converters :</strong></p>
  
  <p>They refer to each-other, like cyclic reference but I don't get stackOverflow exeption. Infact I don't get any errors but no matter whatever I set the value of rate or amount both remains 0. I also know why they remains 0. But don't know the solution.</p>