Herman Cordes
Herman Cordes

Reputation: 4976

How to create a WPF TabControl with multiple headers per TabItem?

Description:

Currently I'm in the process of creating a WPF application where the main content should be presented in a TabControl.

The TabControl exists of:

Styling of WPF controls is not the problem, but this case requires some special behaviour of the control itself. The problem is that the control should render multiple Headers per TabItem.

Questions:

Thanks in advance.

Update #1

In response to vortex a prototype of such a control (as you can see, the external control is the Microsoft Office InfoPath FormControl):

   <TabControl x:Name="FormViewsTabControl">
      <TabItem>
         <TabItem.Headers>
            <TabItemHeader Text="View A" />
            <TabItemHeader Text="View B" />
         </TabItem.Headers>
         <TabItem.Content>
            <winforms:WindowsFormsHost x:Name="InfoPathFormsHost">
               <infopath:FormControl x:Name="InfoPathFormControl" />
            </winforms:WindowsFormsHost>
         </TabItem.Content>
      </TabItem>
      <TabItem Header="Letter">
         <local:CustomView />
      </TabItem>
   </TabControl>

Upvotes: 0

Views: 2256

Answers (3)

Sahadevan
Sahadevan

Reputation: 323

We used the following link

[http://zamjad.wordpress.com/2011/09/21/using-contenttemplateselector/]

when we faced with these type of issue

Upvotes: 0

Amry
Amry

Reputation: 4971

You can have it so that the TabItem.Header contains a Panel element, which can contain multiple child elements. Example:

<TabItem>
  <TabItem.Header>
    <StackPanel>
      <TextBlock Text="View A" />
      <TextBlock Text="View B" />
    </StackPanel>
  </TabItem.Header>
  <TabItem.Content>
    <winforms:WindowsFormsHost x:Name="InfoPathFormsHost">
      <infopath:FormControl x:Name="InfoPathFormControl" />
    </winforms:WindowsFormsHost>
  </TabItem.Content>
</TabItem>

Upvotes: 0

BigL
BigL

Reputation: 1631

If i understand it correctly then you would like to change the TabItems header depending on which view you select in your external control. If that's the case then you should try to expand your external control with a property which holds the actual header value and then bind this to the TabItmes header.

Upvotes: 1

Related Questions