title: Bind event to ViewModel
body: <p>I am using WPF and PRISM framework for my application. The pattern I am using is MVVM (Model - View - ViewModel) and I am trying to bring the MouseLeftButtonUp event from the code-behind in the View to the ViewModel (so the event will be according the MVVM rules). For now I have this:</p>
  
  <p>View.xaml:</p>
  
  <pre><code>&lt;DataGrid x:Name="employeeGrid" Height="250" Margin="25,0,10,0" ItemsSource="{Binding DetacheringenEmployeesModel}" IsReadOnly="True" ColumnHeaderStyle="{DynamicResource CustomColumnHeader}" AutoGenerateColumns="False" RowHeight="30"&gt;
          &lt;i:Interaction.Triggers&gt;
              &lt;i:EventTrigger EventName="MouseLeftButtonUp"&gt;
                   &lt;i:InvokeCommandAction Command="{Binding EmployeeGrid_MouseLeftButtonUp}" /&gt;
              &lt;/i:EventTrigger&gt;
          &lt;/i:Interaction.Triggers&gt;
  &lt;DataGrid.Columns&gt;
  </code></pre>
  
  <p>View.xaml.cs (code-behind):</p>
  
  <pre><code>public partial class UC1001_DashBoardConsultants_View
  {
      public UC1001_DashBoardConsultants_View(UC1001_DashboardConsultantViewModel viewModel)
      {
              InitializeComponent();
              DataContext = viewModel;
      }
  }
  </code></pre>
  
  <p>ViewModel.cs:</p>
  
  <pre><code> public void EmployeeGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
   {
       // insert logic here
   }
  </code></pre>
  
  <p>The main idea is, when I click on a cell in the DataGrid, the event will fire. I first tried it in the code behind, and it worked. I got so far with the EventTriggers, but when I debug and click on a cell, my debugger doesn't come into the method.</p>
  
  <p>Does anyone have an idea how to fix this? Thanks in advance!</p>
  
  <p>PS: Does it also work with the (object sender) parameter when I do it like that? Because I need the DataGrid in my ViewModel to get the ActiveCell I just clicked on.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The event-binding worked with the Command!</p>
  
  <p>I have this in my DataGrid:</p>
  
  <pre><code>&lt;DataGridTextColumn Header="Okt" Width="*" x:Name="test" &gt;
       &lt;DataGridTextColumn.ElementStyle&gt;
             &lt;Style TargetType="{x:Type TextBlock}"&gt;
               &lt;Setter Property="Tag" Value="{Binding Months[9].AgreementID}"/&gt;
  </code></pre>
  
  <p>How can I bind the Tag property to the ViewModel? I know it's already bound from the ViewModel, but as you can see the value comes from an Array/List and per column the value is different.</p>