Hi. I'm using a WPF validation for TextBox validation. I have defined this Template:
<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}" BasedOn="{StaticResource StyleTextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
<Setter Property="Background" Value="{StaticResource TextBox_ErrorBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{StaticResource TextBox_ErrorBorderBrush}"/>
<Setter Property="BorderThickness" Value="2"/>
</Trigger>
</Style.Triggers>
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel>
<TextBlock DockPanel.Dock="Right" Foreground="Red" FontSize="20" Text="!"/>
<AdornedElementPlaceholder/>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The TextBox is located on a form in a TabItem. Everything works fine, but the '!' TextBlock stays visible when I choose other TabItems. This behaviour is observed in many other cases - when expander expands etc.. the Excklamation always stays visible on the same place, although the TextBox is not diplayed.