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?
In WPF, the Label control does not support text wrapping. If you need a label that wraps contents across multiple lines, you can use a TextBlock control. Place a TextBlock control inside a Label and apply wrapping on TextBlock.
Use the wrap() Method in Python One commonly used method is wrap(content, width=length) . Content is the text we need to wrap, and width represents the number of characters per line. The default number of characters is 70 . After wrapping the text, we will use the join() method to join the lines into a single string.
Put simply, if you type a very long piece of text, it disappears off the side of the page, unlike this comment box where it wraps the text around into many lines. If you use the return key to wrap the text, instead of starting a new line, it runs the program.
You are probably missing TextAlignment:
<TextBlock TextAlignment="Center" />
HorizontalAlignment will center the TextBlock, TextAlignment will align the text inside the textblock.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With