With textbox, it works well when I put the following xml in App.xml :
<Style TargetType="{x:Type TextBox}" x:Key="TextBoxValidationStyle">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
But it only works for textbox, how to do a similar thing with DataGridTextColumn ?
Simply use DataGridTextColumn.ElementStyle
and/or DataGridTextColumn.EditingElementStyle
, for example:
<DataGridTextColumn MinWidth="80" ...>
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With