DataGridCell simulation error pattern

I want the TextBox on my TextBoxDataGridColumn to display a red background when the cell value is invalid. I could not get rid of the annoying red border by default.

How to do it?

Thanks!

0
source share
2 answers

Just add this style to your control resources, it should work for all text fields in your control, and then -

<Style x:Key="{x:Type TextBox}" TargetType="TextBox"> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <Border Background="Red" Opacity="0.5" ToolTip="{Binding ElementName=adorner,Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"> <AdornedElementPlaceholder Name="adorner"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> 
0
source
-1
source

Source: https://habr.com/ru/post/1401637/


All Articles