In This Topic
    In This Topic

    The following example demonstrates how to changed the background color of a DataRow according to the value of one of its cells using DataTriggers.

    XAML
    Copy Code
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
      <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                           Source="{Binding Source={x:Static Application.Current},
                                                            Path=Orders}"/>
       <Style TargetType="{x:Type xcdg:DataRow}">
         <Style.Triggers>
           <DataTrigger Binding="{Binding Path=[EmployeeID]}" Value="1">
             <Setter Property="Background" Value="Pink"/>
           </DataTrigger>
           <DataTrigger Binding="{Binding Path=[EmployeeID]}" Value="3">
             <Setter Property="Background" Value="Blue"/>
           </DataTrigger>
         </Style.Triggers>
       </Style>
     </Grid.Resources>
    <xcdg:DataGridControl x:Name="OrdersGrid"
                            ItemsSource="{Binding Source={StaticResource cvs_orders}}"/>
    </Grid>