How to put WPF Tab Control tabs on the side

后端 未结 1 1957
故里飘歌
故里飘歌 2021-01-31 17:07

I am trying to create a Tab Control in WPF that has the tabs arranged down the right side of the control, with the text rotated 90 degrees The look is similar to those plastic t

相关标签:
1条回答
  • 2021-01-31 17:42

    The effect I believe you are seeking is achieved by providing a HeaderTemplate for the TabItem's in you Tab collection.

    <TabControl TabStripPlacement="Right">
      <TabControl.Resources>
        <Style TargetType="{x:Type TabItem}">
          <Setter Property="Padding" Value="4" />
          <Setter Property="HeaderTemplate">
            <Setter.Value>
              <DataTemplate>
                <ContentPresenter Content="{TemplateBinding Content}">
                  <ContentPresenter.LayoutTransform>
                    <RotateTransform Angle="90" />
                  </ContentPresenter.LayoutTransform>
                </ContentPresenter>
              </DataTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </TabControl.Resources>
      <TabItem Header="Tab Item 1" />
      <TabItem Header="Tab Item 2" />
      <TabItem Header="Tab Item 3" />
      <TabItem Header="Tab Item 4" />
    </TabControl>
    

    Hope this helps!

    0 讨论(0)
提交回复
热议问题