views:

32

answers:

1

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

+6  A: 

You are probably missing TextAlignment:

<TextBlock TextAlignment="Center" />

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

Francesco De Vittori
...and I was looking for Alignment and ContentAlignment and I have no clue how could I have missed the TextAlignment when I was selecting TextWrapping from IntelliSense... (I have one of my shaky days - I already spilled a full cup of tea all over my desk... should probably have stayed in bed this morning :-))
Peter Perháč