In the WPF DataGrid, when the user does something that causes an error, we color the line with a red foreground using a StyleSelector:
Public Class LineItemsGridRowStyleSelector
Inherits StyleSelector
Public Property LineItemExceptionStyle
Public Overrides Function SelectStyle(ByVal item As Object, ByVal container As DependencyObject) As Style
If TypeOf item Is OrderEntryLineItem Then
If CType(item, OrderEntryLineItem).HasExceptions Then
Return LineItemExceptionStyle
End If
End If
Return Nothing
End Function
End Class
Our XAML then has this:
<DataGrid.RowStyleSelector>
<local:LineItemsGridRowStyleSelector LineItemExceptionStyle="{StaticResource LineItemRowExceptionStyle}" />
</DataGrid.RowStyleSelector>
Which references this:
<Style x:Key="LineItemRowExceptionStyle" TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource {x:Type DataGridRow}}">
<Setter Property="Foreground" Value="Red"/>
</Style>
Using the default WPF DataGrid theme from Microsoft, the line turns red. However, it no longer turns red when using any of your themes. Am I doing something wrong?