title: Firing a RelayCommand from a button inside a WPF DataGrid
body: <p>I have a <code>DataGrid</code> showing a list of customers defined in XAML as follows bound to my ViewModel:</p>
  
  <pre><code>&lt;DataGrid Name="CustomersDataGrid" ItemsSource="{Binding Customers}"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTemplateColumn&gt;
              &lt;DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Button Command="{Binding showCustomerCommand}" 
                          Content="{Binding Path=Name}"/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/DataGridTemplateColumn.CellTemplate&gt;
          &lt;/DataGridTemplateColumn&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>The display of the grid works fine. I want to be able to display the particulars of an individual customer. Previously, I had setup a binding for the selected row, and had a button on the page which was bound to the following command:</p>
  
  <pre class="lang-cs prettyprint-override"><code>RelayCommand _showCustomerCommand;
  public ICommand showCustomerCommand
  {
      get
      {
          if (_showCustomerCommand == null)
          {
              _showCustomerCommand = new RelayCommand(param =&gt; this.ShowCustomer());
          }
          return _showCustomerCommand;
      }
  }
  
  private void ShowCustomer()
  {
      if (Parent != null)
      {
          // Handle Customer Display Here
      }
  }
  </code></pre>
  
  <p>This worked fine. But I want to be able to click a button inside the individual row, rather than the single button based on selected row. I know the datacontext is wrong in the above XAML, but I don't know how to correct it, nor how to pass out the specific row from which the button press originated. Any and all suggestions to help me wire up my embedded button are gratefully received!</p>