title: WPF Validation.HasError setting Margin on a TextBox
body: <p>I've been trying everything to figure this issue out. :(</p>
  
  <p>For a TextBox, I have a Validation.ErrorTemplate setup with an image on the right hand side of the textbox while it has a validation error.</p>
  
  <p>This works great!  But one thing I want to do is to resize or set the margin the textbox that has the error so it fits within the space the textbox has on the form.  Currently, the image flows outside of the textboxes area.</p>
  
  <p>What I really want is the textbox with error to take up the same space as textbox without.</p>
  
  <p>Here is my XAML style:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type TextBox}"&gt;
  &lt;Style.Resources&gt;
    &lt;my:TextBoxWidthTransformConverter x:Key="TextBoxWidthTransformConverter"/&gt;
  &lt;/Style.Resources&gt;
  &lt;Style.Triggers&gt;
    &lt;Trigger Property="Validation.HasError" Value="true"&gt;
      &lt;Setter Property="Foreground" Value="Red"/&gt;
      &lt;Setter Property="Margin" Value="{Binding Converter={StaticResource TextBoxWidthTransformConverter}, RelativeSource={RelativeSource Self}}"/&gt;
      &lt;Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}"/&gt;
    &lt;/Trigger&gt;
  &lt;/Style.Triggers&gt;
  &lt;Setter Property="Validation.ErrorTemplate"&gt;
    &lt;Setter.Value&gt;
      &lt;ControlTemplate&gt;
        &lt;StackPanel 
          Margin="{TemplateBinding Margin}"
          Orientation="Horizontal" 
          RenderOptions.BitmapScalingMode="NearestNeighbor"
          &gt;              
          &lt;AdornedElementPlaceholder 
            Grid.Column="1" 
            Grid.Row="1" 
            Name="controlWithError" 
            /&gt;
          &lt;Border Width="2"/&gt;
          &lt;Image 
            ToolTip="{Binding ElementName=controlWithError, Path=AdornedElement.(Validation.Errors).CurrentItem.ErrorContent}" 
            Source="imagepath"
            /&gt;
        &lt;/StackPanel&gt;
      &lt;/ControlTemplate&gt;
    &lt;/Setter.Value&gt;
  &lt;/Setter&gt;
  </code></pre>
  
  <p></p>
  
  <p>I'm using a converter TextBoxWidthTransformConverter just to see if I can get something to happen, but before I was just using "0,0,20,0" in the Value, to no avail.  The converter doesn't fire, the Margin doesn't change.  I've used Snoop to see if I can see the property being touched or changed, but nothing happens.  </p>
  
  <p>Is Margin a property that can't be changed by the Validation.HasError property?</p>
  
  <p>Any insight would be wonderful!</p>
  
  <p>Thanks!</p>