2010-10-17 14 views

Odpowiedz

74

Czy próbowałeś TabControl.TabStripPlacement Property?

Poniższy przykład ilustruje tworzenie kontrolki tabulacji, która umieszcza zakładki po lewej stronie.

<TabControl TabStripPlacement="Left" Margin="0, 0, 0, 10"> 
    <TabItem Name="fontweight" Header="FontWeight"> 
    <TabItem.Content> 
     <TextBlock TextWrapping="WrapWithOverflow"> 
     FontWeight property information goes here. 
     </TextBlock> 
    </TabItem.Content> 
    </TabItem> 

    <TabItem Name="fontsize" Header="FontSize"> 
    <TabItem.Content> 
     <TextBlock TextWrapping="WrapWithOverflow"> 
     FontSize property information goes here. 
     </TextBlock> 
    </TabItem.Content> 
    </TabItem> 
</TabControl> 
13

Należy wypróbować ten kod:

<TabControl.Resources> 
      <Style TargetType="{x:Type TabItem}"> 
       <Setter Property="HeaderTemplate"> 
        <Setter.Value> 
         <DataTemplate> 
          <ContentPresenter Content="{TemplateBinding Content}"> 
           <ContentPresenter.LayoutTransform> 
            <RotateTransform Angle="270" /> 
           </ContentPresenter.LayoutTransform> 
          </ContentPresenter> 
         </DataTemplate> 
        </Setter.Value> 
       </Setter> 
       <Setter Property="Padding" Value="3" /> 
      </Style> 
     </TabControl.Resources> 
0

podstawie odpowiedzi rkirac za wyżej. Jeśli nie chcesz tworzyć stylu globalnego, możesz umieścić te same elementy wewnątrz kodu TabControl.ItemContainerStyle, które będą dotyczyć tylko określonego TabControl. Oto prosty przykład:

<TabControl TabStripPlacement="Left"> 
    <TabControl.ItemContainerStyle> 
    <Style TargetType="TabItem"> 
     <Setter Property="LayoutTransform"> 
     <Setter.Value> 
      <RotateTransform Angle="270" /> 
     </Setter.Value> 
     </Setter> 
    </Style> 
    </TabControl.ItemContainerStyle> 
</TabControl>