I created my own error template to show validation errors. Here is my XAML:
<Style TargetType="Control" x:Key="myErrorTemplate">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Right"
Foreground="Red"
FontSize="26"
FontWeight="Bold"
Text=" !"
Margin="0,-8,0,0" />
<Border>
<AdornedElementPlaceholder Name="myControl" />
</Border>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
This will result in an exclamation mark next to the TextBox when a validation error occurs. This template will currently display an error hint when the mouse hovers over a TextBox. I want to show a tooltip when I hover over an exclamation mark (text block). How to achieve this?
source
share