0
votes

Suppose I make the following screen in my app (this is just an example, actual layout is a bit more complex but works on the same principle):

  • Vertical StackPanel
    • TextBlock (fits/wraps its content size AKA Auto size)
    • Button 1 (Auto)
    • Button 2

I would like to make Button 2 stretch so that it occupies the remainder of the screen's height, so there cannot be a specific Height property - but VerticalAlignment="Stretch" and VerticalAlignment="Bottom" don't do the trick, and in fact don't do anything at all. Is there any way to handle that?

2

2 Answers

0
votes

Change the StackPanel to a Grid with 3 rows, first two of Auto size and the last *.

0
votes

in this case i generally prefer to use a grid, you can use something like this:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
</Grid>