How to set DataGrid's row Background, based on a property value using data bindings
In my XAML code, I want to set the Background color of each row, based on a value of the object in one specific row. I have an ObservableCollection of z , and each of the z has a property called State . I started out with something like this in my DataGrid : <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Setter Property="Background" Value="{Binding z.StateId, Converter={StaticResource StateIdToColorConverter}}"/> </Style> </DataGrid.RowStyle> This is a wrong approach because x is not a property in my ViewModel class. In my ViewModel class I have an ObservableCollection<z> which is the