Question

I currently have a custom TabItem which has a custom header, which is defined as part of a Style like this:

<Setter Property="Template">
     <Setter.Value>
         <ControlTemplate TargetType="{x:Type t:TwitterListTabItem}">
             <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Margin="0,-2,0,0" >
                 <Grid SnapsToDevicePixels="true">
                     <ContentPresenter x:Name="Content" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="{TemplateBinding Padding}"/>
                     <Button x:Name="PART_Close"  HorizontalAlignment="Right" Margin="0" Padding="4"  VerticalAlignment="Top" Width="16" Height="16" Style="{DynamicResource CloseableTabItemButtonStyle}" ToolTip="Close Tab">
                         <Path x:Name="Path" Stretch="Fill" StrokeThickness="0.5" Fill="#FFFFFF" Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                     </Button>
                     <Button x:Name="PART_Number"  HorizontalAlignment="Right" Padding="0" Margin="0" VerticalAlignment="Bottom" Width="16" Height="16" Style="{DynamicResource CloseableTabItemNumberStyle}" ToolTip="New Tweets" Content="{TemplateBinding NewTweetsNumber}" />
                 </Grid>
             </Border>

             <ControlTemplate.Triggers>
                 .....Triggers Removed for Shortness....
             </ControlTemplate.Triggers>
         </ControlTemplate>
     </Setter.Value>
</Setter

Now I want to set the template for the content area of the TabItem. I cannot work out how to do this. I have tried setting ContentTemplate, with a <ControlTemplate> containing a ListBox, but it didn't work.

So how do i define a template to control the content?

Thanks in advance

Was it helpful?

Solution

Use the TabItem.HeaderTemplate property for your tab header, and the TabItem.Template property for your tab's contents. Example.

OTHER TIPS

Looks like you need one more ContentPresenter which displays the Content. And you already have a ContentPresenter which is displays Header.

<ContentPresenter ContentSource="Content"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top