I have the following class
:
public class Order
{
public int Id { get; set; }
public string OrdName { get; set; }
public int Quant { get; set; }
public int Supplied { get; set; }
}
and this DataGrid
:
<DataGrid x:Name="dgOrders" Margin="5" CanUserAddRows="False" CanUserDeleteRows="False"
SelectionMode="Extended" ItemsSource="{Binding}"
SelectionUnit="FullRow" VerticalScrollBarVisibility="Auto"
Height="300" Width="700" HorizontalAlignment="Left" AutoGenerateColumns="False" Grid.Row="2">
<DataGrid.Columns>
<DataGridTextColumn Header="Order Name" Binding="{Binding OrdName}" IsReadOnly="True"/>
<DataGridTextColumn Header="Quantity" Binding="{Binding Quant}" IsReadOnly="True"/>
<DataGridTextColumn Header="Supplied" Binding="{Binding Supplied}" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
What I want is that when the Quantity
and Supplied
properties are equal the row background color will change.
I tried it with an Event Trigger
and a Converter
but with no luck (possibly I didn't implement them in the xaml
correctly).
also trying to do this from the code behind didn't work (tried to get the row instance like this suggests but I keep getting null
for the row).