title: WPF MVVM, Increment and Decrement Datagrid Cell Value on Button Click
body: <p><a href="https://i.stack.imgur.com/6hjde.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6hjde.jpg" alt="enter image description here"></a></p>
  
  <p>how do i increment cell value when i click plus button and decrement on minus button</p>
  
  <pre><code>public class ProductModel
  {
      public decimal Product_Quantity { get; set; }
      ...
  </code></pre>
  
  <p>Observeable Collection in viewmodel</p>
  
  <pre><code>private ObservableCollection&lt;ProductModel&gt; mProducts;
  public ObservableCollection&lt;ProductModel&gt; Products
  {
      get { return mProducts; }
      set { mProducts= value; }
  }
  </code></pre>
  
  <p>SelectedRow</p>
  
  <pre><code> private ProductModel mSelectedRow;
   public ProductModel SelectedRow
   {
      get =&gt; mSelectedRow;
      set
      {
          mSelectedRow = value;
          OnPropertyChanged("SelectedRow");
      }
   }
  </code></pre>
  
  <p>Datagrid binding</p>
  
  <pre><code>ItemsSource="{Binding Products}"
  SelectedItem="{Binding SelectedRow}"
  </code></pre>
  
  <p>and here is my DataGridTextColumn where i want to show updated value</p>
  
  <pre><code>&lt;DataGridTextColumn
      Width="auto"
      MinWidth="50"
      Binding="{Binding Product_Quantity}"
      ElementStyle="{StaticResource BlockDataGridTextColumn}"
      Header="Quantity"/&gt;
  </code></pre>
  
  <p>and finaly</p>
  
  <pre><code>private ICommand mIncrementCommand;
      public ICommand IncrementCommand
      {
          get
          {
              if (mIncrementCommand == null)
              {
                  mIncrementCommand = new DelegateCommand(delegate ()
                  {
                      // logic goes here
                  });
              }
              return mIncrementCommand;
          }
      }
  </code></pre>
  
  <p>Updated, i want somthing like below</p>
  
  <pre><code>private ICommand mIncrementCommand;
      public ICommand IncrementCommand
      {
          get
          {
              if (mIncrementCommand == null)
              {
                  mIncrementCommand = new DelegateCommand(delegate ()
                  {
                      SelectedRow.Product_Quantity++;
                  });
              }
              return mIncrementCommand;
          }
      }
  </code></pre>
  
  <p>Solved, Thanks Rahul Agarwal</p>
  
  <pre><code>public class ProductModel : BaseViewModel
  {
      public decimal Product_Quantity { get; set; }
      ...
  </code></pre>
  
  <p>I forgot to implement INotifyPropertyChanged</p>