Venkat S. Rao
Venkat S. Rao

Reputation: 1110

TabControl will not stretch

I am failing at getting a tab control inside a tab control to fill its container. I think it is some simple property I am overlooking or have not found yet. In the xaml below I would like the TabControl 'sub' to completely fill the canvas 'canvas2'.

Thank You, Venkat

<Border BorderBrush="AliceBlue" BorderThickness="1,1,1,1">
    <TabControl name="Main">
        <TabItem Header="Test1">
            <DockPanel LastChildFill="True">
                <Border BorderBrush="Green" BorderThickness="1,1,1,1">
                    <Canvas Width="350" Height="200" DockPanel.Dock="Left">

                    </Canvas>
                </Border>
                <Border BorderBrush="Red" BorderThickness="1,1,1,1">
                    <Canvas name="canvas2">
                        <Border BorderBrush="Yellow" BorderThickness="1,1,1,1">                                
                                <TabControl Height="600" HorizontalAlignment="Stretch"  name="sub">
                                    <TabItem Header="Rights Test 1" HorizontalAlignment="Stretch">
                                        <Canvas></Canvas>
                                    </TabItem>
                                    <TabItem Header="Rights Test 2">
                                        <Canvas></Canvas>
                                    </TabItem>
                                </TabControl>                                
                        </Border>
                    </Canvas>
                </Border>
            </DockPanel>
        </TabItem>
    </TabControl>
</Border>

Upvotes: 0

Views: 1474

Answers (1)

Ben Schoepke
Ben Schoepke

Reputation: 789

Canvas's do not stretch to fill their given space. So get rid of canvas2.

Upvotes: 2

Related Questions