locked
Vertical alignment and TextBlock Height readjustment RRS feed

  • Question

  • I'm in the process retargeting my app to windows 8.1, what was a simple display of items in stack panel in windows 8 (VS 2012) has become retarded in windows 8.1 (VS 2013)

    I'm displaying 3 textblocks in a stack panel

    and I get the display where the middle textblock overlap with the first text block and height of the second textblock does not get adjusted according to font size of 40.

    Similarly for the third textblock I set the vertical alignment to "Bottom"  but the third textblock does not go down. So basically Vertical Alignment setting does not make any difference at all.

    I'm sorry I wish I could show the stack panel in picture, but  I do not have any software like snag it to capture the picture.

    <StackPanel Grid.Column="1" Grid.Row="2" Background="Transparent" Transitions="{StaticResource EntranceVerticalTransition}" > <TextBlock Text="Free Keys" Style="{StaticResource BaseTextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="25" FontWeight="Bold" /> <TextBlock Text="{Binding KeysAvailable}" Style="{StaticResource BaseTextBlockStyle}" FontSize="40" HorizontalAlignment="Center" FontWeight="Bold" Margin="0,5" /> <TextBlock Text="Remaining" Style="{StaticResource BaseTextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="25" FontWeight="Bold" /> <!--<TextBlock Text="Free Keys" Style="{StaticResource SummaryTextStyle}"/> <TextBlock Text="{Binding KeysAvailable}" Style="{StaticResource SummaryDataStyle}"/> <TextBlock Text="Remaining" Style="{StaticResource SummaryTextBottomStyle}"/>--> </StackPanel>


    • Edited by biprism Thursday, January 30, 2014 1:55 PM
    Thursday, January 30, 2014 3:45 AM

Answers

  • Without having a working app, it's hard to say exactly what the problem is.  however, Stackpanel "smashes" all of the content together as small as it will go, so vertical alignment in a vertically-oriented stackpanel that does not have a defined height doesn't really have meaning.  I think if you size the stackpanel, you'll have a better experience.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, January 30, 2014 8:03 PM
    Moderator