Align text block to bottom of page

I am trying to align the version of a Windows Phone application at the bottom of the page. He places it below (below) in all components. But not to the bottom of my page

<StackPanel> <TextBlock Text="Username:" Margin="12,0,0,0"/> <TextBox Text="{Binding UserName, Mode=TwoWay}" c4f:TextBinding.UpdateSourceOnChange="True" InputScope="EmailUserName" /> <TextBlock Text="Password:" Margin="12,0,0,0"/> <PasswordBox Password="{Binding Password, Mode=TwoWay}" c4f:TextBinding.UpdateSourceOnChange="True" /> <Button Content="Next" IsEnabled="{Binding CanMoveNext}" Command="{Binding LoginCommand}"/> <TextBlock Text="{Binding ConnectionError}" TextWrapping="Wrap" FontSize="{StaticResource TitleSize}"></TextBlock> <TextBlock Text="{Binding VersionNumber}" Height="450" Padding="3" TextWrapping="Wrap" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="15"></TextBlock> </StackPanel> 

I want this to be at the bottom of the page.

+5
source share
2 answers

You can use the Grid for this:

 <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <StackPanel Grid.Row="0"> ... </StackPanel> <TextBlock Grid.Row="1" Text="{Binding VersionNumber}" Padding="3" TextWrapping="Wrap" HorizontalAlignment="Center" FontSize="15"/> </Grid> 

This Grid contains two rows. The second line takes up the same height as necessary for its contents, the first line takes up the remaining height. A good article explaining this can be found at visualstudiomagazine.com: Windows Phone Layout Using Grid

+8
source

Do not use the StackPanel for this, as the StackPanel will use as much space as necessary for its contents (it will not fill the page).

A Grid may be a good choice here, as DockPanel can, although DockPanel not available on a Windows phone. Set a few rows for the Grid , so the bottom element is on the bottom row (where you want). Actually it can be two lines: one for your "main" content and one for a footer.

For DockPanel set the item to be at the bottom with DockPanel.Dock="Bottom" and the rest (in order) with DockPanel.Dock="Top" . You may need to set the LastChildFill property to "False" to get the look you want.

0
source

Source: https://habr.com/ru/post/1200440/


All Articles