title: How to pass an entity bound in a DataGrid as a CommandParameter of a Button
body: <p>I have the following DataGrid </p>
  
  <pre><code>&lt;DataGrid&gt;
  &lt;DataGrid.Columns&gt;
  &lt;DataGridTextColumn Header="Registro" Binding="{Binding NumeroRegistro}"    /&gt;
  &lt;DataGridTextColumn Header="Nome" Binding="{Binding Nome}" Width="*" /&gt;
  &lt;DataGridTextColumn Header="Login" Binding="{Binding Login}" Width="200" /&gt;
  &lt;DataGridTemplateColumn Width="30"  &gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;Button Name="btnEditarFisioterapeuta" CommandParameter="{Binding Id}" Click="btnEditarFisioterapeuta_Click"&gt;
                  &lt;Rectangle&gt;
                      &lt;Rectangle.Fill&gt;
                          &lt;VisualBrush Visual="{StaticResource appbar_page_edit}" /&gt;
                      &lt;/Rectangle.Fill&gt;
                  &lt;/Rectangle&gt;
              &lt;/Button&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
  &lt;/DataGridTemplateColumn&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>And, in the code behind I populate the items of the data grid like this</p>
  
  <pre><code>dgFisioterapeuta.ItemsSource = listOfEntities;
  </code></pre>
  
  <p>Nothing special. Note that I'm binding the <code>Id</code> of the entity in the <code>Button</code>, so that in the code behind I can get this <code>Id</code> and edit the entity. I was wondering, if the whole <code>DataGrid</code> is bound to a list of entities, why not pass the entire entity as <code>CommandParameter</code>?</p>
  
  <p>Is there a way to do it?</p>
  
  <p>In other words, I want to Change the line</p>
  
  <pre><code>&lt;Button Name="btnEditarFisioterapeuta" CommandParameter="{Binding Id}" &gt;
  </code></pre>
  
  <p>to something like this.</p>
  
  <pre><code>&lt;Button Name="btnEditarFisioterapeuta" CommandParameter="{Binding The_binding_that_represents_the_entity_of_this_row}" &gt;
  </code></pre>