title: wpf eventsetter handler binding in style
body: <p>I have a style, and I want to bind a command to the <code>EventSetter</code>'s <code>Handler</code> with <code>RelativeSource</code>. The command is in the viewModel.</p>
  
  <pre><code>&lt;Style x:Key="ItemTextBlockEventSetterStyle" TargetType="{x:Type TextBlock}"&gt;
      &lt;EventSetter Event="MouseLeftButtonDown" 
                   Handler="{Binding TextBlockMouseLeftButtonDownCommand, 
                             RelativeSource={RelativeSource Self}}"/&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The problem is that I get an error, because something is wrong with this (maybe it's not possible to do this in such easy way)</p>
  
  <p>I've googled a lot before, and I found the <code>AttachedCommandBehaviour</code>, but I think it doesn't work with style.</p>
  
  <p>Could you give some hints on how to solve this problem?</p>
  
  <p><strong>Update  13/10/2011</strong></p>
  
  <p>I found this in the MVVM Light Toolkit <code>EventToCommand</code> example program:</p>
  
  <pre><code>        &lt;Button Background="{Binding Brushes.Brush1}"
              Margin="10"
              Style="{StaticResource ButtonStyle}"
              Content="Simple Command"
              Grid.Row="1"
              ToolTipService.ToolTip="Click to activate command"&gt;
          &lt;i:Interaction.Triggers&gt;
              &lt;i:EventTrigger EventName="Click"&gt;
                  &lt;cmd:EventToCommand Command="{Binding SimpleCommand}" /&gt;
              &lt;/i:EventTrigger&gt;
              &lt;i:EventTrigger EventName="MouseLeave"&gt;
                  &lt;cmd:EventToCommand Command="{Binding ResetCommand}" /&gt;
              &lt;/i:EventTrigger&gt;
          &lt;/i:Interaction.Triggers&gt;
      &lt;/Button&gt;
  </code></pre>
  
  <p>But here, the binding isn't in the style. How can I put this <code>EventToCommand</code> to the style of the button?</p>