When a TextBox element has an error The custom adorner doesn't resize the StackPanel the Textbox control lies in:
[![enter image description here](https://i.stack.imgur.com/2vn49.png)](https://i.stack.imgur.com/2vn49.png)

Using DockPanel.Bottom causes the adorner to overlap on the Textbox below. 
The code I shamelessly lifted off <http://hirenkhirsaria.blogspot.ie/2013/05/wpf-input-validation-using-mvvm.html>:

```
 <ControlTemplate.Resources>
        <Style x:Key="textblockErrorTooltip" TargetType="TextBlock">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Margin" Value="10 0 10 0" />
        </Style>
    </ControlTemplate.Resources>
    <DockPanel LastChildFill="true">
            <Border Height="Auto" Margin="5,0,0,0" Background="#DC000C" CornerRadius="3" DockPanel.Dock="Right">
                <TextBlock Style="{StaticResource textblockErrorTooltip}" Text="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
            </Border>
        <AdornedElementPlaceholder Name="customAdorner">
            <Border BorderBrush="#DC000C" BorderThickness="1.3" />
        </AdornedElementPlaceholder>
    </DockPanel>
</ControlTemplate>

```

Sure, I could use Z Index but I don't like it.

Is there a way to cause the StackPanel to resize on error?

I was thinking of adding a ContentTemplate after each Textbox control:

```
<StackPanel>
  <TextBox/>
  <ContentTemplate/>
</StackPanel>

<StackPanel>
  <TextBox/>
  <ContentTemplate/>
</StackPanel>

```

The ContentTemplate generates an error info DataTemplate which I believe should cause the StackPanel to resize. 
But I can't figure out how the binding to `(Validation.Errors)[0].ErrorContent}` should be done.
My terrible attempt:

```
        <UserControl.Resources>
             <DataTemplate x:Key="errorinfo">
                <TextBlock>Hello World</TextBlock>
            </DataTemplate>
        </UserControl.Resources>
     <StackPanel Orientation="Horizontal" Grid.Row="4">
         <Label  Padding="0,0,20,0">Name:</Label>
            <StackPanel>
              <TextBox  Padding="0,0,10,0" Width="150" x:Name="name" Text="{Binding Path=Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"></TextBox>
            </StackPanel>
            <ContentControl >
               <ContentControl.Style>
                 <Style  TargetType="ContentControl">
                    <Setter Property="ContentTemplate" Value="{x:Null}"/>
                        <Style.Triggers>
                          <DataTrigger Binding="{Binding ElementName=name, Path=(Validation.HasError)}"  Value="True">
 <Setter Property="ContentTemplate">
                                        <Setter.Value>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding ElementName=name, Path=(Validation.Errors)[0].ErrorContent}"> </TextBlock>
                                            </DataTemplate>
                                        </Setter.Value>
                                    </Setter>
                         </DataTrigger>
                        </Style.Triggers>
                            </Style>
                        </ContentControl.Style>
            </ContentControl>
          </StackPanel>

```

I can't reuse the datatemplate though! 

My question is similar to: [WPF- Validation -The validation error message goes behind the other controls because of AdornerDecorator](https://stackoverflow.com/questions/4552313/wpf-validation-the-validation-error-message-goes-behind-the-other-controls-bec) 

I just want a different solution.

Any ideas? Thanks