共用方式為


FlowDocument.TextAlignment 屬性

定義

取得或設定值,指出文字內容的水平對齊方式。

public:
 property System::Windows::TextAlignment TextAlignment { System::Windows::TextAlignment get(); void set(System::Windows::TextAlignment value); };
public System.Windows.TextAlignment TextAlignment { get; set; }
member this.TextAlignment : System.Windows.TextAlignment with get, set
Public Property TextAlignment As TextAlignment

屬性值

TextAlignment

其中一個 TextAlignment 值,可指定想要的對齊方式。 預設為 Left

範例

下列範例示範如何設定 TextAlignment 專案的 屬性 FlowDocument

<FlowDocumentReader>
  <FlowDocument
    TextAlignment="Center"
>
    <Paragraph Background="GhostWhite">
      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>
</FlowDocumentReader>

下圖顯示上述 FlowDocument Left 文字對齊方式 (預設) 的方式。

螢幕擷取畫面:TextAlign 屬性值為 Left

下圖顯示文字對齊方式的相同 FlowDocument 轉譯 Right 方式。

螢幕擷取畫面:TextAlign 屬性值為 Right

下圖顯示文字對齊方式的相同 FlowDocument 轉譯 Center 方式。

螢幕擷取畫面:TextAlign 屬性值為 Center

下列範例示範如何以程式設計方式設定 TextAlignment 屬性。

FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));

// Text will be centered.
flowDoc.TextAlignment = TextAlignment.Center;
Dim flowDoc As New FlowDocument(New Paragraph(New Run("A bit of text content...")))

' Text will be centered.
flowDoc.TextAlignment = TextAlignment.Center

備註

相依性屬性資訊

識別碼欄位 TextAlignmentProperty
中繼資料屬性設定為 true AffectsMeasureAffectsRenderInherits

適用於