This project is read-only.

How can I change 'RibbonTablItem' header style?

Oct 8, 2014 at 3:26 AM
Edited Oct 8, 2014 at 3:46 AM
I just want to change the style of header in RibbonTabItem.

When I focus RibbonTabItem, I want to change font weight of header to bold.

I tried it like this, but it didn't work.
<r:RibbonTabItem x:Name="ModelTab">
                <r:RibbonTabItem.Header>
                    <TextBlock Text="Model">
                        <TextBlock.Style>
                            <Style TargetType="{x:Type TextBlock}">
                                <Style.Triggers>
                                    <Trigger Property="Selector.IsSelected" Value="True">
                                        <Setter Property="Foreground" Value="Red" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                </r:RibbonTabItem.Header>

...
Please advise if you have any ideas.
Oct 8, 2014 at 5:24 AM
Edited Oct 8, 2014 at 5:24 AM
Because the textblock is not focused. You should bind to the ancestors IsSelect property.
Marked as answer by batzen on 10/9/2014 at 11:52 AM
Oct 8, 2014 at 4:05 PM
Edited Oct 8, 2014 at 4:05 PM
batzen wrote:
Because the textblock is not focused. You should bind to the ancestors IsSelect property.
Thx, batzen~!

I solved it like this.
...
<Style x:Key="RibbonTabItemHeaderStyle_Bold" TargetType="{x:Type TextBlock}">
    <Style.Triggers>
        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type r:RibbonTabItem}}}" Value="True">
            <Setter Property="FontWeight" Value="Bold" />
        </DataTrigger>
    </Style.Triggers>
</Style>
...
<r:RibbonTabItem x:Name="ModelTab">
    <r:RibbonTabItem.Header>
        <TextBlock Text="Model" Style="{StaticResource RibbonTabItemHeaderStyle_Bold}" />
    </r:RibbonTabItem.Header>
...
Marked as answer by batzen on 10/9/2014 at 11:52 AM