Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF TabControl Position Tabs in the top right corner

I have a WPF TabControl that I want to position the tabs with a TabStripPlacement of Top, but I want them to display with a right orientation on top. I've achieved that easily by doing a FlowDirection of RightToLeft; however, I don't want the children controls to inherit the RightToLeft FlowDirection.

Is there any way to position the tabs on the top on the right without using the FlowDirection property?

like image 608
Aaron Avatar asked Feb 03 '10 14:02

Aaron


2 Answers

This question is old, but it is what came up when I google searched. The answer wasn't really what I wanted. So I researched this in Expresion Blend. I determined that the TabPanel needs to have HorizontalAlignment="Right" style. So for future, it is as easy as this:

<TabControl>
    <TabControl.Resources>
        <Style TargetType="TabPanel">
            <Setter Property="HorizontalAlignment" Value="Right"/>
        </Style>
    </TabControl.Resources>
    <TabControl.Items>
        <TabItem Header="Tab 1"></TabItem>
        <TabItem Header="Tab 2"></TabItem>
        <TabItem Header="Tab 3"></TabItem>
    </TabControl.Items>
</TabControl>

Let me know if you see any issues with this.

like image 162
Rhyous Avatar answered Nov 14 '22 10:11

Rhyous


I'm not sure about this, you could always try creating a custom style for the TabControl to specify how the tabs are laid out. Alternatively, just use FlowDirection and specify the FlowDirection as LeftToRight on each individual TabItem so the child controls display normally.

like image 39
TabbyCool Avatar answered Nov 14 '22 10:11

TabbyCool