Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

align a text block to bottom of page

I am trying to align the version of my windows phone application to bottom center of the page. It places it to bottom (below) all the components in view. But not to 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 it to be at bottom of the page.

like image 796
Somu Avatar asked Aug 15 '14 19:08

Somu


1 Answers

You can use a 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 row takes as much height as needed by its content, the first row takes the remaining height. A nice article explaining this can be found on visualstudiomagazine.com: Windows Phone Layout Using Grid

like image 70
venerik Avatar answered Sep 28 '22 10:09

venerik