locked
Create Multiple Rows in Tab Control. RRS feed

  • Question

  • Hi,

    I have a Tab Control. This is placed inside a Stack Panel. This has enough space for 3 tabs. Now i want to add a fourth tab and it is not wrapping. I did some research and found that if we use any Style or ControlTemplate, this will prevent the Tabcontrol from wrapping.

    Following is the code for ControlTemplate that i use for the TabControl.

    <Style TargetType="{x:Type TabControl}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type TabControl}">
                                <Grid Height="525">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <TabPanel Grid.Row="0" Panel.ZIndex="1" Margin="0,0,4,-1" IsItemsHost="True" Background="Transparent" />
                                    <Border Grid.Row="1" BorderBrush="Black" BorderThickness="1" CornerRadius="0, 12, 12, 12">
                                        <Border.Background>
                                            <LinearGradientBrush>
                                                <GradientStop Color="#BEC39F" Offset="0" />
                                                <GradientStop Color="White" Offset="1" />
                                            </LinearGradientBrush>
                                        </Border.Background>
                                        <ContentPresenter ContentSource="SelectedContent" />
                                    </Border>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

    Can someonepls tell me how to tweak the above code to make the TabControl wrap the tabs in it.

    Thanks,

    Shailendra

    Wednesday, November 7, 2012 10:33 PM

Answers

  • I think i know what the problem is. Once i added width property to the following line, the tabs wrapped around. Since there is no width, i think it was all aligned in a line instead of wrapping.

            <Grid VerticalAlignment="Top" Height="700" Width="315">
    • Marked as answer by Shailendra_G Thursday, November 29, 2012 6:52 PM
    Thursday, November 29, 2012 6:52 PM

All replies

  • Can someone please reply to my question ....
    Thursday, November 29, 2012 5:17 PM
  • I think i know what the problem is. Once i added width property to the following line, the tabs wrapped around. Since there is no width, i think it was all aligned in a line instead of wrapping.

            <Grid VerticalAlignment="Top" Height="700" Width="315">
    • Marked as answer by Shailendra_G Thursday, November 29, 2012 6:52 PM
    Thursday, November 29, 2012 6:52 PM