WPF TabControl Position Tabs in the top right corner
Asked Answered
C

3

6

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?

Cirri answered 3/2, 2010 at 14:22 Comment(0)
D
5

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.

Digitate answered 3/2, 2010 at 17:40 Comment(2)
Thank you for taking the time to reply! I should clarify that I am setting the FlowDirection of each TabItem to LeftToRight which works on the display side. I'm trying to accomplish the following: grumpydev.com/2009/01/03/taking-wpf-screenshots. The screenshots are captured, but they are backwards when the TabControl FlowDirection is set to RightToLeft.Cirri
I took your suggestion and used a custom style and set the TabPanel tag's FlowDirection like so: <TabPanel Grid.Row="0" IsItemsHost="true" FlowDirection="RightToLeft"/>. Then I left the TabControl's FlowDirection to RightToLeft. This achieved what I was looking for. Thanks again!Cirri
L
7

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.

Lac answered 19/3, 2014 at 19:57 Comment(0)
D
5

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.

Digitate answered 3/2, 2010 at 17:40 Comment(2)
Thank you for taking the time to reply! I should clarify that I am setting the FlowDirection of each TabItem to LeftToRight which works on the display side. I'm trying to accomplish the following: grumpydev.com/2009/01/03/taking-wpf-screenshots. The screenshots are captured, but they are backwards when the TabControl FlowDirection is set to RightToLeft.Cirri
I took your suggestion and used a custom style and set the TabPanel tag's FlowDirection like so: <TabPanel Grid.Row="0" IsItemsHost="true" FlowDirection="RightToLeft"/>. Then I left the TabControl's FlowDirection to RightToLeft. This achieved what I was looking for. Thanks again!Cirri
E
0

Similar to Rhyous solution, but with fixing tabs arrangement

<TabControl>
    <TabControl.Resources>
        <Style TargetType="TabPanel">
            <Setter Property="FlowDirection" Value="RightToLeft"/>
        </Style>
    </TabControl.Resources>
    <TabControl.Items>
        <TabItem Header="Tab 1"></TabItem>
        <TabItem Header="Tab 2"></TabItem>
        <TabItem Header="Tab 3"></TabItem>
    </TabControl.Items>
</TabControl>
Elated answered 25/4, 2021 at 7:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.