Style first row (only) in Datagrid.

Sep 30, 2009 at 2:12 PM


I would like to change the styling of the first row (only) in a WPF Datagrid but haven't found how to do it. I wondered about creating a trigger, something like this:

<Style TargetType="{x:Type dg:DataGridRow}">
<Trigger Property="SelectedIndex" Value="0">
<Setter Property="Background" Value="Red"/>

But of course this doesn't work since there is no 'SelectedIndex' property on DataGridRow. I have also had some attempts at doing this in my code behind but couldn't get it to work.

It seems like something that out to be fairly simple but I haven't managed it, so any advice would be most appreciated.

Thanks, Will