So, I got a huge style template dictionary for every control and for ValidationErrorTemplate as well. The problem is, that we should show validation error below the control when there is no place above the control. Basicly for controls at the top of the window. For controls at the bottom of the window the validation should be shown above the control.
Since it a resource dictionary where every styles are defined there is no code-behind and also no data binding is possible.
One idea would be to determine the AdornedElementPlaceholder
's position and hide / show the template respectivly. But I haven't find any solution to do that in XAML.
<ControlTemplate x:Key="ValidationErrorTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Border>
<AdornedElementPlaceholder />
</Border>
</Grid>
<AdornerDecorator Grid.Row="????">
<Border >
<!-- some style comes here ... -->
</Border>
</AdornerDecorator>
</Grid>
</ControlTemplate>
Grid.Row="????" should be either 0 or 1, depending on the top of the control.