Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

want to make scrollable tabs for a tabcontrol

Tags:

Say I have a tab control, and I have over 50 tabs, where there is no enough space to hold so many tabs, how make these tabs scrollable?

like image 709
demaxSH Avatar asked Apr 17 '11 00:04

demaxSH


1 Answers

Rick's answer actually breaks the vertical stretching of content inside the tabcontrol. It can be improved to retain vertical stretching by using a two row grid instead of a StackPanel.

<TabControl.Template>             <ControlTemplate TargetType="TabControl">                 <Grid>                     <Grid.RowDefinitions>                         <RowDefinition Height="Auto" />                         <RowDefinition />                     </Grid.RowDefinitions>                     <ScrollViewer HorizontalScrollBarVisibility="Auto"  VerticalScrollBarVisibility="Hidden" >                         <TabPanel x:Name="HeaderPanel"                           Panel.ZIndex ="1"                            KeyboardNavigation.TabIndex="1"                           Grid.Column="0"                           Grid.Row="0"                           Margin="2,2,2,0"                           IsItemsHost="true"/>                     </ScrollViewer>                     <ContentPresenter x:Name="PART_SelectedContentHost"                                       SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"                                       Margin="{TemplateBinding Padding}"                                       ContentSource="SelectedContent" Grid.Row="1"/>                 </Grid>             </ControlTemplate>         </TabControl.Template> 
like image 190
Kyeotic Avatar answered Nov 03 '22 15:11

Kyeotic