I have a Stack and I have a Grid inside of Stack.
I need to increase Stack and Grid sizes when I resize the window. I set Stack and Grid HorizontalAlignment to 'Stretch'
Stack works fine but grid sizes don't raises when I resize the window
This is my code.
<StackPanel Background="Blue" Orientation="Horizontal" HorizontalAlignment="Stretch" Grid.Column="1" Margin="13,0,0,0" >
<Grid HorizontalAlignment="Stretch" Background="Beige" Width="515">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="240" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Image x:Name="imageMap" Source="Resources/images.jpg" HorizontalAlignment="Stretch" Grid.Row="0" Stretch="Fill" Margin="0,0,0,0" />
</Grid>
</StackPanel>
Please advise
Even if you removed with Width from the Grid, it won't work because the StackPanel's orientation is set to Horizontal. When it is set like this, the StackPanel gives it's children exactly the amount of width they say they need during the measure layout pass See Layout here.
To fix this, you'll need to change the orientation to Vertical, or use a different container such as a DockPanel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With