tags:

views:

162

answers:

2

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>

Now i want to set the template for the content area of the tab item. I cannot work out how to do this. I have tried setting ContentTemplate, with a <ControlTemplate> containing a Listbox, but it didnt work. So how do i define a template to control the content?

Thanks in advance

+1  A: 

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

RandomEngy
Gives the Error'System.Windows.Controls.ControlTemplate' is not a valid value for the 'System.Windows.Controls.HeaderedContentControl.HeaderTemplate' property on a Setter.
lloydsparkes
This has an example of how to use both template properties: http://msdn.microsoft.com/en-us/library/system.windows.controls.headeredcontentcontrol.headertemplate%28lightweight%29.aspx
RandomEngy
A: 

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

<ContentPresenter ContentSource="Content"/>
Jobi Joy
I have looked at this before, but it doesnt solve my problem, because it wont let me define the controls inside
lloydsparkes