Highlight the RowDetails in a DataGrid when row is selected

datagrid, wpf, xaml

Solution

This worked for me:

<DataGrid.RowDetailsTemplate>
 <DataTemplate>
  <Border>
   <Border.Style>
    <Style TargetType="Border">
      <Style.Triggers>
       <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="True">
        <Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}"/>
      </DataTrigger>
    </Style.Triggers>
   </Style>
   </Border.Style>
   <StackPanel>
     <!-- my details content here --> 
   </StackPanel>
  </Border>
 </DataTemplate>
</DataGrid.RowDetailsTemplate>

Problem

I have a `DataGrid` with `RowDetailsVisibilityMode` set to `Visible`. Now when I select a row I would like to highlight the details area too, while the default is that only row cells are highlighted. Any hint to get this kind of behavior?

Original source