Tuesday, 19 March 2013

WPF DataGrid RowStyle

To change the style of the rows in a DataGrid use the DataGrid.RowStyle and set the required properties. In order to retain the bulk of the standard DataGridRow style, including alternating row colours and mouseover row highlighting add the BasedOn attribute to the Style tag.

  <Style TargetType="DataGridRow"
            BasedOn="{StaticResource {x:Type DataGridRow}}">
    <DataTrigger Binding="{Binding BeingActioned}"
      <Setter Property="FontStyle"
                 Value="Italic" />
      <Setter Property="Foreground"
                 Value="Silver" />

No comments: