Peter Perháč
Peter Perháč

Reputation: 20782

TextBlock.TextWrapping - how to make the text wrap so that the lines are center-aligned?

In a Windows Phone 7 application, when I place a TextBlock in the grid and set its HorizontalAlignment to "Center" and its TextWrapping to "Wrap", why does the text that overflows the width of the container and is placed on the next line, align with the left side of the otherwise center-aligned block?

Is there any way to setup text wrapping so that all of the text in the text block is center-aligned?

alt text

Upvotes: 32

Views: 10295

Answers (1)

Francesco De Vittori
Francesco De Vittori

Reputation: 9290

You are probably missing TextAlignment:

<TextBlock TextAlignment="Center" />

HorizontalAlignment will center the TextBlock, TextAlignment will align the text inside the textblock.

Upvotes: 69

Related Questions