So I have created my own TabControl and TabItem templates (both with x:Name attribute), and I use them like this:
<Style TargetType="TabControl">
<Setter Property="Template" Value="{DynamicResource MyTabControl}" />
</Style>
As expected, this makes all TabControls in the window use MyTabControl template, however it still uses the old TabItem template. How can I make it work so the code above somehow manages to style every TabItem inside that template to use MyTabItem template?
Of course I could just edit the MyTabControl template and set the template manually, but that would require me to use something else than TabPanel container (probably StackPanel). Is it somehow possible to tell the TabPanel to use specific template for every TabItem?
In MyTabControl I use this to display TabItems:
<TabPanel IsItemsHost="True" />
And I’m looking for something like this (I don’t know if this is possible):
<TabPanel IsItemsHost="True" TabItemsTemplate="MyTabItem" />
I believe this would work:
Create a style for your TabItem, that sets it’s Template to your TabItem Template
and alter your above Style to:
You could also just ignore the above and create a style without a key for your TabItem, and this will set all TabItems to this style.
You could also have a look here:
http://blogs.intuidev.com/post/2010/01/25/TabControlStyling_PartOne.aspx