title: Getting WPF Data Grid Context Menu Click Row
body: <p>I have a WPF DataGrid</p>
  
  <pre><code>&lt;DataGrid AutoGenerateColumns="False"  Name="dataGrid1"  IsReadOnly="True" &gt;
  &lt;DataGrid.Columns&gt;
      &lt;DataGridTextColumn Header="Site" Binding="{Binding Site}" Width="150" /&gt;
      &lt;DataGridTextColumn Header="Subject" Binding="{Binding Subject}" Width="310" /&gt;
  &lt;/DataGrid.Columns&gt;
  &lt;DataGrid.ContextMenu&gt;
      &lt;ContextMenu&gt;
          &lt;MenuItem Header="Delete" Click="Context_Delete"&gt;
              &lt;MenuItem.Icon&gt;
                  &lt;Image Width="12" Height="12" Source="Images/Delete.png" /&gt;
              &lt;/MenuItem.Icon&gt;
          &lt;/MenuItem&gt;
      &lt;/ContextMenu&gt;
  &lt;/DataGrid.ContextMenu&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>I have the click event handler as: </p>
  
  <pre><code>private void Context_Delete(object sender, System.EventArgs e)  { }
  </code></pre>
  
  <p>How do I get the row on which the Context Menu was before the click? The <code>sender</code> object is <code>System.Windows.Controls.MenuItem</code>, not the <code>DataGridRow</code>. How do I get the <code>DataGridRow</code> where the Context Menu was clicked. <em>(I set the <code>DataGrid.ItemSource</code> in the code behind file.)</em></p>