2010-01-08 93 views
0

試圖讓tabcontrol的每個選項卡上的文本垂直顯示。因爲我從來沒有進入控制,什麼不是,我被困住了。找到一些代碼讓文本顯示,就好像它被旋轉到左邊一樣。我希望它能夠顯示,就好像它在標籤上右旋(垂直)一樣。骨架代碼如下:右對齊TabControl上的垂直文本

Protected Sub OnDrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles TabControl1.DrawItem 
    'MyBase.OnDrawItem(e)' 
    Dim tc As TabControl = DirectCast(sender, TabControl) 
    Dim g As Graphics = e.Graphics 
    Dim rectf As RectangleF 
    Dim isVertical As Boolean = (tc.Alignment > TabAlignment.Bottom) 
    Dim off As Integer = 1 : If (e.State And sel) = sel Then off = -1 
    Dim textFormat As New StringFormat(StringFormatFlags.NoClip _ 
           Or StringFormatFlags.NoWrap) 
    With textFormat 
     .HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show 
     .Alignment = StringAlignment.Center 
     .LineAlignment = StringAlignment.Center 
    End With 


    With e.Bounds 
     If isVertical Then 
      ' tabs are aligned left or right' 
      If tc.Alignment = TabAlignment.Left Then 
       Dim m As New System.Drawing.Drawing2D.Matrix 
       m.Translate(0, .Height - tc.TabPages(0).Top) 
       m.RotateAt(270, New PointF(.X, .Y)) 
       g.Transform = m 
       rectf = New RectangleF(.Left - tc.TabPages(0).Top, .Top + off, _ 
             .Height, .Width) 
      ElseIf tc.Alignment = TabAlignment.Right Then 
       'Dim m As New System.Drawing.Drawing2D.Matrix' 
       'm.Translate(0, .Height - tc.TabPages(0).Top)' 
       'm.RotateAt(270, New PointF(.X, .Y))' 
       'g.Transform = m' 
       'rectf = New RectangleF(.Left - tc.TabPages(0).Top, .Top + off, _' 
       '      .Height, .Width)' 
       ' Here is where the tab should go to rotate the text about 180 degrees' 
      End If 
     Else 
      ' tabs are aligned top or bottom' 
      rectf = New RectangleF(.X, .Y + off, .Width, .Height) 
     End If 
    End With 


    Dim col As Color 
    Select Case (e.State And notsf) 
     Case DrawItemState.Disabled 
      col = SystemColors.GrayText 
     Case DrawItemState.HotLight 
      col = SystemColors.HotTrack 
     Case Else 
      col = SystemColors.MenuText 
    End Select 


    g.DrawString(tc.TabPages(e.Index).Text, _ 
       tc.Font, _ 
       New SolidBrush(col), _ 
       rectf, _ 
       textFormat) 

    If isVertical Then g.ResetTransform() 

    If (e.State And selfoc) = selfoc Then 
     ControlPaint.DrawFocusRectangle(g, _ 
        [Rectangle].Inflate(e.Bounds, -1, -1)) 
    End If 
    textFormat.Dispose() 
End Sub 

回答

0

我不使用VB或WinForms,因此以下內容將不在代碼中,幷包含一些猜測。在沒有屏幕截圖的情況下,很難知道與您的描述所需要的不同之處。我是否正確地認爲你只是希望你的標籤的標題文字以另一種方式旋轉180度,即文本的「頂部」與標籤的左側或標籤的右側哪一個不是現在的哪一個?

在分支If tc.Alignment = TabAlignment.Right Then ...文本正由RotateAt通話旋轉:

m.RotateAt(270, New PointF(.X, .Y)) 

,你會想改變270 90有在另一個方向旋轉的文本。

(你熟悉設立這樣的變換矩陣?同樣的原則也適用於OpenGL或DirectX編程。如果沒有,評論,我會解釋/鏈接)。

如果你只是這樣做,那麼機會文本是不可見的,因爲它將被旋轉以關閉您正在繪製的位圖。您需要翻譯它,以便文本的開頭位於右側角落。這就是我上面提到的猜測的地方:我不熟悉你使用的圖形框架的座標系,所以我不知道要翻譯哪個方向。對不起,我不能給你工作代碼,但我只是沒有Visual Studio和一個.NET Winforms控件來試驗:)我可以看到你已經在這裏沿着這些線做了一些事情:

m.Translate(0, .Height - tc.TabPages(0).Top) 

我的猜測是你需要改變這個,所以X座標(0)是.Width.Width - [text height, calculate this],你可能還需要考慮Y座標中的文本寬度。 (文本「高度」和「寬度」好像文本是水平/正常繪製的。)我很確定.net的繪圖框架可能包括GraphicsTextHeight(...)TextWidth(...)方法,如果它不是這些名稱我是確定他們很容易找到:) TextRect()也許? (如果我坐在你的電腦上,試圖通過純粹的猜測來弄明白這一點,我會編寫這段代碼,這樣它就可以將文本旋轉到一個大的位圖的中間位置,對其進行修改,使其位於左上方位於矩形內部的右圖中的位圖是選項卡的大小,然後將代碼移動到製表符繪製方法中。保存所有帶有一個小小選項卡並運行它的麻煩,然後執行「我的文本在哪裏?「當它被隱藏,因爲它被繪製在錯誤的座標上。)

0

我假設你正在使用XAML,這可以實現通過樣式

添加這些樣式:

<!-- Simple Splitter Style --> 
    <Style x:Key="SimpleSplitterStyle" TargetType="controls:GridSplitter"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="controls:GridSplitter"> 
        <Grid x:Name="Root" IsHitTestVisible="{TemplateBinding IsEnabled}"> 
         <Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0"/> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

    <!-- Tab Item Header (Right) --> 
    <Style x:Key="RightTabItemHeader" TargetType="ContentControl"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ContentControl"> 
        <ContentPresenter Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" ContentTemplate="{TemplateBinding ContentTemplate}"> 
         <layout:LayoutTransformer > 
          <layout:LayoutTransformer.LayoutTransform> 
           <RotateTransform Angle="90"/> 
          </layout:LayoutTransformer.LayoutTransform> 
          <ContentPresenter Margin="5,0,5,0" /> 
         </layout:LayoutTransformer> 
        </ContentPresenter> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

    <!-- Tab Item Header (Left) --> 
    <Style x:Key="LeftTabItemHeader" TargetType="ContentControl"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ContentControl"> 
        <ContentPresenter Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" ContentTemplate="{TemplateBinding ContentTemplate}"> 
         <layout:LayoutTransformer > 
          <layout:LayoutTransformer.LayoutTransform> 
           <RotateTransform Angle="-90"/> 
          </layout:LayoutTransformer.LayoutTransform> 
          <ContentPresenter Margin="5,0,5,0" /> 
         </layout:LayoutTransformer> 
        </ContentPresenter> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

    <!-- Tab Item Style --> 
    <Style x:Key="TabItemStyle" TargetType="controls:TabItem"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="controls:TabItem"> 
        <Grid x:Name="Root"> 
         <Grid x:Name="TemplateTopSelected" Visibility="Collapsed" Canvas.ZIndex="1"> 
          <Border Margin="-2,-2,-2,0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0"> 
           <Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1,1,0,0"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <Rectangle Fill="#FFFFFFFF" Margin="0,0,0,-2"/> 
             <ContentControl x:Name="HeaderTopSelected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="FocusVisualTop" Margin="-2,-2,-2,0" IsHitTestVisible="false" Visibility="Collapsed" BorderBrush="#FF6DBDD1" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0"/> 
          <Border x:Name="DisabledVisualTopSelected" Margin="-2,-2,-2,0" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="3,3,0,0"/> 
         </Grid> 
         <Grid x:Name="TemplateTopUnselected" Visibility="Collapsed"> 
          <Border x:Name="BorderTop" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" CornerRadius="3,3,0,0"> 
           <Border x:Name="GradientTop" BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1,1,0,0"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <ContentControl x:Name="HeaderTopUnselected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="DisabledVisualTopUnSelected" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="3,3,0,0"/> 
         </Grid> 
         <Grid x:Name="TemplateBottomSelected" Visibility="Collapsed" Canvas.ZIndex="1"> 
          <Border Margin="-2,0,-2,-2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,0,1,1" CornerRadius="0,0,3,3"> 
           <Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="0,0,1,1"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <Rectangle Fill="#FFFFFFFF" Margin="0,-2,0,0"/> 
             <ContentControl x:Name="HeaderBottomSelected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="FocusVisualBottom" Margin="-2,0,-2,-2" IsHitTestVisible="false" Visibility="Collapsed" BorderBrush="#FF6DBDD1" BorderThickness="1,0,1,1" CornerRadius="0,0,3,3"/> 
          <Border x:Name="DisabledVisualBottomSelected" Margin="-2,0,-2,-2" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="0,0,3,3"/> 
         </Grid> 
         <Grid x:Name="TemplateBottomUnselected" Visibility="Collapsed"> 
          <Border x:Name="BorderBottom" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" CornerRadius="0,0,3,3"> 
           <Border x:Name="GradientBottom" BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="0,0,1,1"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <ContentControl x:Name="HeaderBottomUnselected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="DisabledVisualBottomUnSelected" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="0,0,3,3"/> 
         </Grid> 
         <Grid x:Name="TemplateLeftSelected" Visibility="Collapsed" Canvas.ZIndex="1"> 
          <Border Margin="-2,-2,0,-2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,0,1" CornerRadius="3,0,0,3"> 
           <Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1,0,0,1"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <Rectangle Fill="#FFFFFFFF" Margin="0,0,-2,0"/> 
             <ContentControl x:Name="HeaderLeftSelected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Style="{StaticResource LeftTabItemHeader}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="FocusVisualLeft" Margin="-2,-2,0,-2" IsHitTestVisible="false" Visibility="Collapsed" BorderBrush="#FF6DBDD1" BorderThickness="1,1,0,1" CornerRadius="3,0,0,3"/> 
          <Border x:Name="DisabledVisualLeftSelected" Margin="-2,-2,0,-2" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="3,0,0,3"/> 
         </Grid> 
         <Grid x:Name="TemplateLeftUnselected" Visibility="Collapsed"> 
          <Border x:Name="BorderLeft" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3,0,0,3"> 
           <Border x:Name="GradientLeft" BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1,0,0,1"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <ContentControl x:Name="HeaderLeftUnselected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Style="{StaticResource LeftTabItemHeader}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="DisabledVisualLeftUnSelected" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="3,0,0,3"/> 
         </Grid> 
         <Grid x:Name="TemplateRightSelected" Visibility="Collapsed" Canvas.ZIndex="1"> 
          <Border Margin="0,-2,-2,-2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,1,1" CornerRadius="0,3,3,0"> 
           <Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="0,1,1,0"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <Rectangle Fill="#FFFFFFFF" Margin="-2,0,0,0"/> 
             <ContentControl x:Name="HeaderRightSelected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Style="{StaticResource RightTabItemHeader}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="FocusVisualRight" Margin="0,-2,-2,-2" IsHitTestVisible="false" Visibility="Collapsed" BorderBrush="#FF6DBDD1" BorderThickness="0,1,1,1" CornerRadius="0,3,3,0"/> 
          <Border x:Name="DisabledVisualRightSelected" Margin="0,-2,-2,-2" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="0,3,3,0"/> 
         </Grid> 
         <Grid x:Name="TemplateRightUnselected" Visibility="Collapsed"> 
          <Border x:Name="BorderRight" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" CornerRadius="0,3,3,0"> 
           <Border x:Name="GradientRight" BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="0,1,1,0"> 
            <Border.Background> 
             <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> 
              <GradientStop Color="#FFFFFFFF" Offset="0"/> 
              <GradientStop Color="#F9FFFFFF" Offset="0.375"/> 
              <GradientStop Color="#E5FFFFFF" Offset="0.625"/> 
              <GradientStop Color="#C6FFFFFF" Offset="1"/> 
             </LinearGradientBrush> 
            </Border.Background> 
            <Grid> 
             <ContentControl x:Name="HeaderRightUnselected" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" IsTabStop="False" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Style="{StaticResource RightTabItemHeader}"/> 
            </Grid> 
           </Border> 
          </Border> 
          <Border x:Name="DisabledVisualRightUnSelected" IsHitTestVisible="false" Opacity="0" Background="#8CFFFFFF" CornerRadius="0,3,3,0"/> 
         </Grid> 
         <Border x:Name="FocusVisualElement" Margin="-1" IsHitTestVisible="false" Visibility="Collapsed" BorderBrush="#FF6DBDD1" BorderThickness="1" CornerRadius="3,3,0,0"/> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

,然後你可以指定這個到每個標籤項:

  <controls:TabControl TabStripPlacement="Right" Margin="4"> 
      <controls:TabItem Header="First" Style="{StaticResource TabItemStyle}"> 
       <controls:TreeView> 
        <controls:TreeViewItem Header="Parent 1" /> 
        <controls:TreeViewItem Header="Parent 2"> 
         <controls:TreeViewItem Header="Child 1"> 
          <controls:TreeViewItem Header="Grandchild 1" /> 
         </controls:TreeViewItem> 
        </controls:TreeViewItem> 
        <controls:TreeViewItem Header="Parent 3"> 
         <controls:TreeViewItem Header="Child 1"> 
          <controls:TreeViewItem Header="Grandchild 1" /> 
          <controls:TreeViewItem Header="Grandchild 2" /> 
         </controls:TreeViewItem> 
        </controls:TreeViewItem> 
       </controls:TreeView> 
      </controls:TabItem> 
      <controls:TabItem Header="Second" Style="{StaticResource TabItemStyle}"> 
       <controls:TreeView> 
        <controls:TreeViewItem Header="Parent 1" /> 
        <controls:TreeViewItem Header="Parent 2"> 
         <controls:TreeViewItem Header="Child 1"> 
          <controls:TreeViewItem Header="Grandchild 1" /> 
         </controls:TreeViewItem> 
        </controls:TreeViewItem> 
        <controls:TreeViewItem Header="Parent 3"> 
         <controls:TreeViewItem Header="Child 1"> 
          <controls:TreeViewItem Header="Grandchild 1" /> 
          <controls:TreeViewItem Header="Grandchild 2" /> 
         </controls:TreeViewItem> 
        </controls:TreeViewItem> 
        <controls:TreeViewItem Header="Parent 4"> 
         <controls:TreeViewItem Header="Child 1"> 
          <controls:TreeViewItem Header="Grandchild 1" /> 
          <controls:TreeViewItem Header="Grandchild 2" /> 
          <controls:TreeViewItem Header="Grandchild 3" /> 
          <controls:TreeViewItem Header="Grandchild 4" /> 
          <controls:TreeViewItem Header="Grandchild 5" /> 
          <controls:TreeViewItem Header="Grandchild 6" /> 
          <controls:TreeViewItem Header="Grandchild 7" /> 
          <controls:TreeViewItem Header="Grandchild 8" /> 
         </controls:TreeViewItem> 
        </controls:TreeViewItem> 
       </controls:TreeView> 
      </controls:TabItem> 
     </controls:TabControl> 

現在您可以從頂部/底部/右側/左側進行更改,文本將在右側/左側垂直噸。在這個例子中,我只剩下頂部和底部,但是這應該給你很多關於如何控制這些標籤的想法。

+1

不使用xaml ...這是爲winforms – bbqchickenrobot 2010-01-29 05:57:13