2010-07-05 103 views
-1

我有一个自定义ItemsControl(WorKArea),它将所有项目都标记为WorkSheet实例。在TabItem中显示自定义内容的问题可见

我有一个ItemsControl的样式,它使用TabControl来显示内容。每张纸创建一个标签。风格是:

<Style TargetType="{x:Type local:WorkArea}"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type local:WorkArea}"> 
       <TabControl ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WorkArea}}, Path=Items}"> 
        <TabControl.ItemContainerStyle> 
         <Style TargetType="TabItem"> 
          <Setter Property="Header" Value="{Binding Title}" /> 
         </Style> 
        </TabControl.ItemContainerStyle> 
       </TabControl> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

到目前为止好。出现“图纸”,标题正确绑定到页眉。

如何获取显示内容的选项卡?无论我尝试什么,每个WorkSheet都不会显示任何内容 - 内容始终为空。任何人的正确的代码?

回答

0

你的工作区域应该提供一个ContentTemplate属性,而TabControl应该有一个TemplateBinding