views:

19

answers:

1

I have a simple WPF Forms app. I have a DockPanel as my root panel. The first child is a StackPanel that has some controls in it, then the second control is a TabControl. What I want, and the panel types can change all they want is for the TabControl to maintain the fill size of the window except for what the first StackPanel consumes. However no matter what I try the TabControl seems to change its size depending on whats inside it, not whats it is inside of.

<Window>
    <DockPanel>
        <StackPanel> </StackPanel>
        <TabControl> </TabControl>
    </DockPanel>
</Window>
+1  A: 

Just set the HorizontalAlignment and VerticalAlignment properties of your TabControl to "Stretch":

<DockPanel>
    <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="5">
        <TextBlock Text="Hello" />
        <TextBlock Text="World" />
    </StackPanel>

    <TabControl HorizontalAlignment="Stretch" 
                VerticalAlignment="Stretch">
        <TabItem Header="Small">
            <TextBlock Text="Just Some Small Stuff" />
        </TabItem>
        <TabItem Header="Bigger">
            <StackPanel>
                <TextBlock Text="One line" />
                <TextBlock Text="The next line" />
            </StackPanel>
        </TabItem>

    </TabControl>
</DockPanel>
Wonko the Sane
Well, how about that. That works great. Had I fiddled around long enough I would have figured it out, but truth be told I am more of a web guy than a WPF/XAML guy! Thanks!
CrazyDart
No problem. I'm more of a WPF/XAML guy. ;)
Wonko the Sane