Skip to content

Text alignment is not working #19287

Answered by tobyfirth
NotQuiteLoona asked this question in Q&A
Discussion options

You must be logged in to vote

TextAlignment aligns the text within the amount of space that the text box is taking up. The alignment is relative to the size of the text box. As you are using a canvas the text box is only sized to the amount of space required to show the text.

Compare these two samples of a canvas and a stack panel (I have added a border of clarity)

<Border Width="300" Height="328" BorderBrush="Black" BorderThickness="2">
    <Canvas >
        <TextBlock FontSize="20" TextAlignment="Center">
            Completed 1 hour 21 minutes
        </TextBlock>
    </Canvas>
</Border>
<Border Width="300" Height="328" BorderBrush="Black" BorderThickness="2">
    <StackPanel>
        <TextBlock FontSize="20" TextA…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NotQuiteLoona
Comment options

Answer selected by NotQuiteLoona
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants