Style first row (only) in Datagrid.

Sep 30, 2009 at 3:12 PM

Hi,

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}">
   
<Style.Triggers>
       
<Trigger Property="SelectedIndex" Value="0">
           
<Setter Property="Background" Value="Red"/>
       
</Trigger>
   
</Style.Triggers>
</Style>

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