0

我目前有一个自定义TabItem的自定义标题,它被定义为这样的一部分Style

<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

现在我想为TabItem. 我无法弄清楚如何做到这一点。我尝试设置 ContentTemplate,其中<ControlTemplate>包含 a ListBox,但它没有用。

那么如何定义模板来控制内容呢?

提前致谢

4

2 回答 2

3

将 TabItem.HeaderTemplate 属性用于选项卡标题,将 TabItem.Template 属性用于选项卡内容。例子

于 2009-10-21T21:50:37.850 回答
0

看起来您还需要一个显示内容的 ContentPresenter。而且您已经有一个 ContentPresenter 显示标题。

<ContentPresenter ContentSource="Content"/>
于 2009-10-22T03:52:51.797 回答