Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put WPF Tab Control tabs on the side

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 tabs you can buy and use in a notebook. I have tried changing the TabStripPlacement to Right, but it just stacks the tabs up on the top right side of the control - not at all what I had in mind.

like image 316
Brian Stewart Avatar asked Oct 09 '08 22:10

Brian Stewart


People also ask

How do I add a tab in WPF?

In WPF, Tabs are very easy to implement. Create a new WPF Window, remove the default Grid tags, and add the following XAML: <TabControl> <TabItem Header="Tab 1">xyz</TabItem>

What is Tab Control WPF?

The WPF TabControl allows you to split your interface up into different areas, each accessible by clicking on the tab header, usually positioned at the top of the control. Tab controls are commonly used in Windows applications and even within Windows' own interfaces, like the properties dialog for files/folders etc.


1 Answers

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!

like image 74
Brad Leach Avatar answered Sep 18 '22 06:09

Brad Leach