user3685285
user3685285

Reputation: 6606

Making a Content Template Apply to Only Select TabItems in TabControl, WPF

I am trying to create dynamic tabs that open and close like in web browsers. However, I am trying to make it such that there is one unchangeable, unclosable tab (like a control tab), which can open up multiple other closable tabs. This tab would be initialized from the start. The unclosable tab has a different format than the closable tabs. I want to write two content templates: one that applies to the control tab, and one that applies to all the closable tabs. Is it possible to have two different content templates for the same TabControl?

Upvotes: 1

Views: 505

Answers (1)

ryand
ryand

Reputation: 324

What you're looking for is to provide templates to the individual TabItems not the entire TabControl. For example in XAML:

   <TabControl>
        <TabItem Template="MyControlTabTemplate" Header="Control Tab"  />
        <TabItem Template="MyOtherTabTemplate" Header="Other Tab" />
   </TabControl>

You can create more TabItems as you wish in the code-behind.

Upvotes: 0

Related Questions