title: update cell in datagrid wpf
body: <p>I have an invoice program that keeps track of items selected that the customer may want to buy. every time that the "add item" button is pushed, the QTY cell increments. The problem im running in to is that the value is getting upgraded in the background, but is not being changed in the cell itself.
  If you click on the cell however, the value will update. But i want it to update as soon as i click that "add item" button. What can i do to update the cell information as i click this button? 
  this is the code i have that works with the button push</p>
  
  <pre><code>public partial class MainWindow : Window
  }
  private void btnAddItem_Click(object sender, RoutedEventArgs e)
      {
          addDataGridRow(invoiceItemID, cbxItems.SelectedItem.ToString(), Convert.ToDouble(txtPrice.Text));
      }
  
      private void addDataGridRow(int id, string itemName, double itemPrice)
      {
          //lstDataItem.Add(new DataItem { sQTY = count.ToString(), sNAME = itemName, sPRICE = itemPrice, sRemove = "Delete Item" });
         // Rows = new ObservableCollection&lt;DataItem&gt; { new DataItem () };
          for (int i = 0; i &lt; Rows.Count; i++)
          {
              if (Rows[i].sNAME == itemName)
              {
                  Rows[i].sQTY = Rows[i].sQTY + 1;
                  id = Rows[i].id;
                  bSameItem = true;
              }
          }
          if (id == 0)
          {
              Rows.Add(new DataItem());
          }
          else if (!bSameItem)
          {
              Rows.Add(new DataItem());
          }
  
  
          if (!bSameItem)
          {
              Rows[id].id = id;
              Rows[id].sQTY = 1;
              Rows[id].sNAME = itemName;
              Rows[id].sPRICE = itemPrice;
              invoiceItemID++;
              dgInvoice.ItemsSource = Rows;
  
          }
          bSameItem = false;
      }
  }
  
  public class DataItem
  {
      public int id { get; set; }
      public int sQTY { get; set; }
      public string sNAME { get; set; }
      public double sPRICE { get; set; }
  }
  </code></pre>
  
  <p>i dont know if you need my xaml but here is it just in case</p>
  
  <pre><code>        &lt;DataGrid x:Name="dgInvoice" HorizontalAlignment="Left" Margin="10,92,0,0" VerticalAlignment="Top" Height="608" Width="488" AutoGenerateColumns="False" ItemsSource="{Binding}" RowHeight="25"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTextColumn Header="QTY" Binding="{Binding Path=sQTY}" Width="100"/&gt;
                  &lt;DataGridTextColumn Header="NAME" Binding="{Binding Path=sNAME}" Width="200"/&gt;
                  &lt;DataGridTextColumn Header="PRICE" Binding="{Binding Path=sPRICE}" Width="80"/&gt;
                  &lt;DataGridTemplateColumn Width="100"&gt;
                      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Button Height="20"&gt;Delete Item&lt;/Button&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
                  &lt;/DataGridTemplateColumn&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p>there is not many responses to wpf that i have seen when i have searched this topic. Any help would be greatly appreciated.</p>