0

I have made a table using a DataGrid with List as its ItemsSource binding. I currently want to change the row styling of my 'Calculation Functions' tab ONLY. I want to be able to set it so that any row in 'Calculation Functions' has the Foreground and Background as Red and all my other tabs remain normal. How would this be possible?

enter image description here

<DataGrid Name="ReflectionDataGrid"SelectedItem="{Binding SelectedItem}" ItemsSource="{Binding List}" AutoGenerateColumns="False" IsHitTestVisible="True">


           <DataGrid.RowStyle>
                <Style TargetType="{x:Type DataGridRow}">
                    
                    <Style.Triggers>
                        <Trigger Property="Header" Value="Calculation Functions">
                            <Setter Property="Background" Value="Red"/>
                            <Setter Property="Foreground" Value="Red"/>
                        </Trigger>
                    </Style.Triggers>
                    
                </Style>
            </DataGrid.RowStyle> 
</DataGrid>
bigboy
  • 35
  • 5

1 Answers1

0

You could bind to the Header property of the SelectedItem of the parent TabControl:

<Style TargetType="{x:Type DataGridRow}">
    <Style.Triggers>
        <DataTrigger Binding="{Binding SelectedItem.Header, RelativeSource={RelativeSource AncestorType=TabControl}}"
                     Value="Calculation Functions">
            <Setter Property="Background" Value="Red"/>
            <Setter Property="Foreground" Value="Red"/>
        </DataTrigger>
    </Style.Triggers>
</Style>
mm8
  • 163,881
  • 10
  • 57
  • 88