Tabs Studio Blog (organizing Visual Studio document tabs)

October 20, 2010

Limiting number of tab rows

Filed under: Uncategorized — Tags: , — Sergey Vlasov @ 8:37 am

Due to popular demand and new tabs panel customization capabilities in Tabs Studio v2.1.2, I’ve created the SingleRow add-in that allows you to limit maximum number of tab rows and show remaining tabs in a drop-down list similar to default Visual Studio behavior:

A single row of tabs and the drop-down list of hidden tabs

A single row of tabs and the drop-down list of hidden tabs


To use SingleRow you need to set tabs layout to Wrap and apply the following style changes:
The Wrap tabs layout option

The Wrap tabs layout option

<Style TargetType="TabsStudio:TabsHost" BasedOn="{StaticResource DefaultTabsHostStyle}">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type TabsStudio:TabsHost}">
        <Grid>
          <Rectangle Width="{TemplateBinding Width}"
                     Height="{TemplateBinding Height}"
                     Fill="{TemplateBinding Background}"/>
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
              <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <ContentPresenter Grid.Column="0"/>
            <TabsStudioSingleRow:HiddenTabs Grid.Column="1" TabsPanel="{TemplateBinding ContentControl.Content}"/>
          </Grid>
        </Grid>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

<Style TargetType="TabsStudio:Tab" BasedOn="{StaticResource DefaultTabStyle}">
  <Style.Triggers>
    <Trigger Property="TabsStudioSingleRow:Properties.IsTabHidden" Value="True">
      <Setter Property="Visibility"  Value="Collapsed"/>
    </Trigger>
  </Style.Triggers>
</Style>

<Style TargetType="TabsStudioSingleRow:HiddenTabs">
  <Setter Property="Content" Value=">"/>
  <Setter Property="Margin" Value="2,0,2,0"/>
  <Setter Property="VerticalAlignment" Value="Center"/>
  <Style.Triggers>
    <Trigger Property="TabsStudioSingleRow:Properties.IsHiddenTabs" Value="False">
      <Setter Property="Visibility"  Value="Collapsed"/>
    </Trigger>
  </Style.Triggers>
</Style>

This style adds the TabsStudioSingleRow:HiddenTabs button to open the drop-down list and binds it to the corresponding TabsPanel. SingleRow doesn’t actually hide tabs – it only sets the IsTabHidden property for them. The style above sets tab visibility based on this property. HiddenTabs button’s appearance is also defined in this style and the button is collapsed when there are no hidden tabs.

Tabs are hidden in the least recently used order and don’t automatically reappear even when space becomes available. Hidden tabs in the drop-down list are sorted alphabetically.

Default number of tab rows is 1, but you can change it in the SingleRow add-in options dialog:

SingleRow options dialog

SingleRow options dialog


Two rows of tabs and the hidden tabs list

Two rows of tabs and the hidden tabs list


Download link: SingleRow v1.0.0.

1 Comment

  1. Wish it can limit the number of tabs too. When the limit reach it will automatically close the oldest tab.

    Comment by Anonymous — August 25, 2012 @ 8:43 am


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Blog at WordPress.com.

%d bloggers like this: