I’m currently using row validation for my datagrid. I’m trying to change the appearance of a row when it is not valid. My code so far in terms of visually reporting the error:
<DataGrid.RowValidationErrorTemplate>
<ControlTemplate>
<Grid Margin="0,-2,0,-2" Background="Red" HorizontalAlignment="Stretch"
ToolTip="{Binding RelativeSource={RelativeSource
FindAncestor, AncestorType={x:Type DataGridRow}},
Path=(Validation.Errors)[0].ErrorContent}">
<TextBlock Text="!" FontSize="{TemplateBinding FontSize}"
FontWeight="Bold" Foreground="White"
HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</DataGrid.RowValidationErrorTemplate>
It seems that this will only affect my header row. Is there a way I can handle this RowValidationErrorTemplate to modify the row appearance? I would like to make the entire row’s background red or anything like that.
Any ideas?
Please let me know if I need to provide more code for this particular problem.
Thanks in advance!
you can update the style of DataGridRow type and try to set error background based on Validation flag against the row.
Something like this…
Let me know if this helps.