Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill all available space in StackPanel

Tags:

wpf

xaml

<Window x:Class="DataBinding_01.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel Height="Auto" Name="stackPanel1" Width="Auto">        
        <TextBox Height="23" Name="textBox1" Width="Auto" />
        <TextBox Height="23" Name="textBox2" Width="Auto" />
        <Button Content="Button" Name="button1" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
    </StackPanel>
</Window>

I want the Button fill all available space on the StackPanel. How can I do it?

like image 978
ceth Avatar asked Feb 18 '12 14:02

ceth


1 Answers

If you mean fill all horizontal and vertical space you should use a DockPanel.

    <DockPanel Height="Auto" Name="stackPanel1" Width="Auto" LastChildFill="True">
        <TextBox DockPanel.Dock="Top" Height="23" Name="textBox1" Width="Auto" />
        <TextBox DockPanel.Dock="Top" Height="23" Name="textBox2" Width="Auto" />
        <Button Content="Button" Name="button1" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
    </DockPanel>
like image 192
Phil Avatar answered Oct 16 '22 01:10

Phil