Wednesday, August 18, 2010

WPF DataGrid Row-level styling

It took me a very long time to figure out how to do this. The following code takes a WPF (and probably silverlight) datagrid and changes the row foreground color based on a single property in that row.

<DataGrid AutoGenerateColumns="True"  Name="dgProjects" >
                <Style TargetType="DataGridRow">
                        <DataTrigger Binding="{Binding Path=HasProblems}" Value="True">
                            <Setter Property="Foreground" Value="Red"/>

No comments:

Post a Comment