Silverlight: stretching to remaining space in StackPanel
Posted
by crimson13
on Stack Overflow
See other posts from Stack Overflow
or by crimson13
Published on 2009-07-07T08:55:05Z
Indexed on
2010/04/09
0:23 UTC
Read the original article
Hit count: 507
Silverlight
|stackpanel
I have a vertical StackPanel with two elements: a Button and a ListBox. How can I have the ListBox stretch to the remaining page height?
<StackPanel Height="Auto" Width="Auto">
<Button Height="30" Width="100" Content="Get Content" x:Name="GetContent"/>
<ListBox Height="Auto" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</StackPanel>
Note that I got this to work using a Grid:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Width="100" Height="30" Content="Get Content" Click="OnGetContent" Grid.Row="0" Grid.Column="0"/>
<data:DataGrid x:Name="MyContent" Margin="0,5" Grid.Row="1" Grid.Column="0"/>
</Grid>
© Stack Overflow or respective owner