I have a global style for all comboboxes in application. For error validation I am using IDataErrorInfo. So when there will be error I want all textboxes to have such custom view: with different ErrorContent (mouse should be over circle to show toolTip with error info). My combobox style is:
<Style x:Key="AlStyleTextBoxArial12" TargetType="{x:Type TextBox}">
<Setter Property="FontFamily" Value="Arial"/>
<Setter Property="FontSize" Value="12pt"/>
<Setter Property="Margin" Value="3,3,3,3"/>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Right" Margin="-23,0,0,0" Width="15" Height="15">
<Grid.ToolTip>
<ToolTip Content="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Grid.ToolTip>
<Ellipse Fill="Red" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
<TextBlock Text="!" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="11pt" FontWeight="Bold" Margin="0,0,0,1"/>
</Grid>
<Border BorderBrush="Red" BorderThickness="1">
<AdornedElementPlaceholder/>
</Border>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
And my TextBox is implemented this way:
<TextBox Text="{Binding Snr, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
Grid.Row="3" Grid.Column="2"/>
View of the TextBox, when I have error, is ok, but I cannot set toolTip. It is always empty. Any ideas why I cann't get ErrorContent?
I've changed my style to this :
and it is working now.