开发者

Customized Content of TabItem WPF

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 <Control开发者_如何学JAVATemplate> containing a ListBox, but it didn't work.

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

Thanks in advance


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


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

<ContentPresenter ContentSource="Content"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜