Tabs Studio Blog (organizing Visual Studio document tabs)

February 26, 2011

Horizontal tab alignment

Filed under: Uncategorized — Tags: , — Sergey Vlasov @ 9:07 pm

In Visual Studio 2010 horizontal tab alignment is a little off, note the close tab button is near the tab name instead of being docked to the right:

Left tab alignment in Visual Studio 2010

Left tab alignment in Visual Studio 2010


In Visual Studio 2008 and even in the Visual Studio 2010 floating tool window tab alignment is correct:
Stretch tab alignment in the floating Visual Studio 2010 tool window

Stretch tab alignment in the floating Visual Studio 2010 tool window


Turns out horizontal tab alignment is Stretch by default in TabItem‘s control template, but also inherited from the HorizontalContentAlignment property of a ItemsControl visual ancestor. Tabs Studio doesn’t use ItemsControl (this is why in Visual Studio 2008 and in the separate Visual Studio 2010 window tab alignment is correct), but there is ItemsControl with HorizontalContentAlignment=Left in Visual Studio IDE that is found when tabs are above the code editor.

I’ve added ItemsControl to Tabs Studio controls tree:

TabsHost : ContentControl
|
 - TabsItemsControl : ItemsControl
   |
    - Tabs : Panel
     |
      - Tab : TabItem

With the default style:

<Style x:Key="DefaultTabsItemsControlStyle0" TargetType="TabsStudio:TabsItemsControl">
  <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>

In the next Tabs Studio release, horizontal tab alignment is Stretch by default in all scenarios:

Fixed stretch tab alignment in Visual Studio 2010

Fixed stretch tab alignment in Visual Studio 2010


If you prefer old left alignment, you will be able to set it with the following custom style:

<Style TargetType="TabsStudio:TabsItemsControl" BasedOn="{StaticResource DefaultTabsItemsControlStyle}">
  <Setter Property="HorizontalContentAlignment" Value="Left"/>
</Style>

Blog at WordPress.com.

%d bloggers like this: