日期:2014-05-17  浏览次数:21066 次

WPF,请问TabItem的控件模板
在VS中,右键TabItem,创建模板副本,看到TabItem的控件模板:

<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
    <Border x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" Margin="0">
        <Border x:Name="innerBorder" BorderBrush="#FFACACAC" BorderThickness="1,1,1,0" Background="White" Margin="-1" Opacity="0"/>
    </Border>
    <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" Focusable="False" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}"/>
</Grid>


TabItem是个内容控件,在其控件模板中,只有一个ContentPresenter,它是用来显示TabItem的Header的吧。怎么没有看到TabItem的Content属性部分是怎么显示的呢?

------解决方案--------------------
ContentPresenter
------解决方案--------------------
请看此处http://blog.csdn.net/lhx527099095/article/details/7999116