2010-07-05 34 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