Block::TextAlignment Property
.NET Framework (current version)
Gets or sets the horizontal alignment of text content.
Assembly: PresentationFramework (in PresentationFramework.dll)
public: property TextAlignment TextAlignment { TextAlignment get(); void set(TextAlignment value); }
Property Value
Type: System.Windows::TextAlignmentOne of the TextAlignment values that specifies the desired alignment. The default is TextAlignment::Left.
The following example shows how to set the TextAlignment attribute of a Block element.
<FlowDocument> <Paragraph Background="GhostWhite" TextAlignment="Center"> One<LineBreak/> two two<LineBreak/> Three Three Three<LineBreak/> four four four four<LineBreak/> Five Five Five Five Five<LineBreak/> six six six six six six<LineBreak/> Seven Seven Seven Seven Seven Seven Seven<LineBreak/> eight eight eight eight eight eight eight eight </Paragraph> </FlowDocument>
The following figure shows how the preceding example renders with Left text alignment (the default).

The following figure shows how the same example renders with Right text alignment.

The following figure shows how the same example renders with Center text alignment.

The following example shows how to set the TextAlignment property programmatically.
.NET Framework
Available since 3.0
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Available since 3.0
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Show: