title: How to fire event from button inside datagrid in silverlight and MVVM
body: <p>I have button at first column in datagrid. I am using MVVM and try to bind Command to Command in ViewModel but when I click button in each row, it don't work (It don't call Command in ViewModel) but if I move that button out of datagrid it's working properly.</p>
  
  <p>How can I fire event from button inside datagrid in MVVM?</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>XAML's code is:</p>
  
  <pre><code>&lt;datagrid:DataGridTemplateColumn.CellTemplate&gt;
      &lt;DataTemplate&gt;
          &lt;StackPanel Orientation="Horizontal" 
                          VerticalAlignment="Center"&gt;
              &lt;Button x:Name="button" Content="View" Margin="5" DataContext="{StaticResource XDataContext}"&gt;
                  &lt;i:Interaction.Triggers&gt;
                      &lt;i:EventTrigger EventName="Click"&gt;
                          &lt;i:InvokeCommandAction Command="{Binding ViewOrganizationCommand}"
                                                  CommandParameter="{Binding ElementName=dtgOrganizations, Path=SelectedItem}" /&gt;
                      &lt;/i:EventTrigger&gt;
                  &lt;/i:Interaction.Triggers&gt;
              &lt;/Button&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
  &lt;/datagrid:DataGridTemplateColumn.CellTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>ViewModel's code is:</p>
  
  <pre><code>public ViewModelCommand ViewOrganizationCommand { get; set; }
  </code></pre>