WPF: Set style on immediate children only
- by ollifant
In my application I have a tab control which has several tab items.
The problem is that I want to apply a style to these tab items, but to no other (nested) tab items.
I have tried setting the following style on the tab control, but this also effects all children:
<Style x:Key="tabControlStyle" TargetType="{x:Type TabControl}">
<Setter Property="TabItem.Template" Value="{StaticResource tabItemTemplate}" />
</Style>
By using the code above I get the following error: 'TabItem' ControlTemplate TargetType does not match templated type 'TabControl', as TabItem and TabControl have the same DependencyProperty "Template", and the code tries to set the TabItemTemplate as TabControl- Template.
Can anybody help me?