In my XAML code, I want to set the Background color of each line based on the value of the object in one specific line. I have an ObservableCollection of z , and each of z has a property called State . I started 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 the wrong approach because x is not a property in my ViewModel class.
In my ViewModel class, I have an ObservableCollection<z> , which is the ItemsSource this DataGrid and a SelectedItem type z .
I could bind the color to the SelectedItem , but this will change only one row in the DataGrid .
How can I change these backgroundcolor strings based on a single property?
wpf xaml wpfdatagrid
Tobias Moe Thorstensen Aug 05 '13 at 8:00 2013-08-05 08:00
source share