Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to Left-Align headers in a WPF TabControl?

Right now, I have a WPF window where all the tab labels of the TabControl are centered.

I'd like the tab levels of the TabControl to be left-aligned.

Is this possible without completely redoing the ControlTemplate?

I tried messing with HorizontalAlignment, HorizontalContentAlignment, etc., but nothing I tried had the desired effect.

If I try this solution (offered by T Levesque):

<TabControl...>
    <TabControl.ItemContainerStyle>
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="HorizontalAlignment" Value="Left"/>
        </Style>
    </TabControl.ItemContainerStyle>
    ...
</TabControl>

...I get this:

All the tab labels of the TabControl are left-aligned, but the tabs don't stretch properly

Which is close, but it ends up looking kind of like a histogram.

like image 268
devuxer Avatar asked Sep 22 '09 00:09

devuxer


1 Answers

Simply adding the attribute HorizontalContentAlignment="Left" to the TabControl will align tab headers left.

<TabControl
Margin="0,5,0,0"
HorizontalContentAlignment="Left"
TabStripPlacement="Left">
<TabItem
    Header="Perform System Administration">
    ...
<TabItem
    Header="Perform Setup Tasks">
    ...
like image 94
SkyBlade Avatar answered Sep 27 '22 23:09

SkyBlade