To query the effective horizontal alignment of Text, use the read-only property effectiveHorizontalAlignment. The text-align property is used to set the horizontal alignment of a text. However, the property horizontalAlignment will remain unchanged. When using the attached property LayoutMirroring::enabled to mirror application layouts, the horizontal alignment of text will also be mirrored. If you want the text to be, say, centered in its parent, then you will need to either modify the Item::anchors, or set horizontalAlignment to Text.AlignHCenter and bind the width to that of the parent. Centering a block or an image vertically.
Works great, but is a major fail if that text needs to wrap. You set the line-height of that text to be equal to the height of the box. In fact, there are three kinds of centering: Centering lines of text. If you only have a single word or a single line of text, there is a clever way to vertically center it in a block with CSS. In this common case, all alignments are equivalent. A common task for CSS is to center text or images. Note that for a single line of text, the size of the text is the area of the text. The valid values for verticalAlignment are Text.AlignTop, Text.AlignBottom and Text.AlignVCenter. The valid values for horizontalAlignment are Text.AlignLeft, Text.AlignRight, Text.AlignHCenter and Text.AlignJustify. Horizontal alignment follows the natural alignment of the text, for example text that is read from left to right will be aligned to the left. By default, the text is vertically aligned to the top. Sets the horizontal and vertical alignment of the text within the Text items width and height. For example, red text with a specific font and size can be defined like this: Text items can display both plain and rich text. effectiveHorizontalAlignment : enumeration.List of all members, including inherited members.