Reputation: 35
So I've got a style, which does some fancy things to a wpf TabControl, among which it sets a HeaderTemplate that allows users to rename the tab. I've got a style which is based on this template that colors the text based on some parameter, and I would like to add a polygon to the header of each tab depending on some conditions.
So the base style looks like:
<Style TargetType="TabItem" x:Key="EditableTabItemStyle"
BasedOn="{StaticResource BaseTabItemStyle}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<controls:EditableTabContent Template="{StaticResource EditableTabItemTemplate}"
Content="{Binding Path=., Mode=TwoWay}"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
and my derived looks like:
<Style x:Key="DerivedTabItem"
BasedOn="{StaticResource EditableTabItemStyle}"
TargetType="TabItem">
<Setter Property="Foreground">
<Setter.Value>
<MultiBinding Converter="{StaticResource StateToColorConverter}">
<Binding Path="States.State1" />
<Binding Path="States.State2" />
</MultiBinding>
</Setter.Value>
</Setter>
I'm looking to add a polygon to the derived style, preferably without changing the base style at all, so my initial thought was to add a header template:
<Setter Property="HeaderTemplate">
<Setter.Value>
<!-- Old header template -->
<!-- Polygon -->
</Setter.Value>
</Setter>
But that overrides the editable styling. I'm not sure if what I want is even possible, so I'll take that for an answer if need be, but if it can be done, how can I do it?
Upvotes: 1
Views: 596
Reputation: 22739
You can't amend an existing template. You can either:
DataTrigger
or a binding to its Visibility
property).
ContentPresenter
that could display all sorts of content by binding it to some placeholder property.In this case, where the template is so simple, I'd go with the former.
Upvotes: 1