Reputation: 345
I have a stack panel and it has one grid and I'd like the grid to have same height as stack panel.
I tried playing with VerticalAlignment
stretch or height 100% nothing works
I tried setting the values programatically OnNavigatedTo
but it doesn't have the effect
Any suggestions to resolve this are welcome
Please find the code below
<StackPanel Grid.Row="0" Grid.RowSpan="4" Background="#CFFF" Visibility="Visible" Orientation="Vertical" Name="ProgressOverlay">
<Grid Name="Overlaygrid"">
<StackPanel VerticalAlignment="Center" Grid.Row="0">
<ProgressBar
IsIndeterminate="True"
IsEnabled="True" Foreground="Black"/>
<TextBlock Visibility="Visible" Foreground="Black" FontSize="25” T HorizontalAlignment="Center" Text="Loading"/>
</StackPanel>
</Grid>
</StackPanel>
Upvotes: 1
Views: 686
Reputation: 10015
A StackPanel
takes by default the size needed by its content and shrinks to the size required, while a container control like Grid
stretches to the full size available (e.g full page).
If you want to keep the outer StackPanel
, you will have to set VerticalAlignment="Stretch"
on the StackPanel
, not on the Grid
.
But since the Grid
is the only single content item in your outer StackPanel
, you can remove it and move the properties Grid.RowSpan="4" Background="#CFFF" Visibility="Visible"
to the Grid
. Always try to keep your XAML structure as simple as possible.
Upvotes: 1