title: WPF Style Validation Trigger Command
body: <p>I have some dynamic generated Textboxes with Validators. I want them to send a Command to VM, if a validation error occurs. This Behavior is placed in a style, so I don't need to write it into the xaml generation.</p>
  
  <p>Here's the Code:</p>
  
  <pre><code>&lt;behaviors:Triggers x:Key="validationTrigger" x:Shared="False"&gt;
      &lt;behaviors:ValidationErrorEventTrigger&gt;
          &lt;cmd:EventToCommand Command="{Binding ValidationError,NotifyOnValidationError=True}"
                              PassEventArgsToCommand="True" /&gt;
      &lt;/behaviors:ValidationErrorEventTrigger&gt;
  &lt;/behaviors:Triggers&gt;
  
  &lt;Style x:Key="EditableTextBox" TargetType="{x:Type TextBox}"&gt;
      &lt;Setter Property="Background" Value="#DDFFDD" /&gt;
      &lt;Setter Property="Validation.ErrorTemplate"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate&gt;
                  &lt;Border BorderBrush="Red" BorderThickness="2"&gt;
                      &lt;AdornedElementPlaceholder /&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Setter Property="behaviors:OCCInteraction.Triggers" Value="{StaticResource ResourceKey=validationTrigger}" /&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="Validation.HasError" Value="true"&gt;
              &lt;Setter Property="Background" Value="#FFDDDD"/&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The Problem I'm having now, is that the "Onvalidation" Event is called in the VlidationErrorEventTrigger class, but the Command isn't called in the Viewmodel.
  I've tested it with a direct integration and not with a style and it works this way.</p>
  
  <p>So maybe it has something to do with the Binding of the Command or so...</p>
  
  <p>I hope this description is enough to solve the Problem. If not please tell me :)</p>