Reputation: 1002
As Mentioned in Title, I want to change the header of my TabControl to be scrollable.
The reason: I have too many tabItems, and the wrapping is not the best solution in my case. so I want to change it from :
To something like that (Scroll bar indicated by the arrow) :
Can anyone help me and show how to do that ? (I'm using wpf)
Upvotes: 10
Views: 7191
Reputation: 33364
Changing TabControl.Template
to something simple like this seems to work for me
<TabControl ...>
<TabControl.Template>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<TabPanel x:Name="HeaderPanel" IsItemsHost="True" Margin="0,4,0,0"/>
</ScrollViewer>
<ContentPresenter x:Name="PART_SelectedContentHost" Margin="4" ContentSource="SelectedContent" Grid.Row="1"/>
</Grid>
</ControlTemplate>
</TabControl.Template>
</TabControl>
Upvotes: 16