FlowDocument.LineHeight 屬性

定義

取得或設定每行內容的高度。

public:
 property double LineHeight { double get(); void set(double value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))]
public double LineHeight { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))>]
member this.LineHeight : double with get, set
Public Property LineHeight As Double

屬性值

範圍從 0.0034 到 160000 的每行行高 (以與裝置無關的像素為單位)。 NaN 的值 (相當於 "Auto" 的屬性值) 會使行高由目前字型特性自動決定。 預設值為 NaN

屬性

例外狀況

LineHeight 會設為非正數值。

範例

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

<FlowDocumentReader>
  <FlowDocument
    FontSize="24"
    LineHeight="48"
  >
    <Paragraph TextAlignment="Left" Background="AliceBlue">
      One<LineBreak/>
      two two<LineBreak/>
      Three Three Three<LineBreak/>
      four four four four<LineBreak/>
      Five Five Five Five Five
    </Paragraph>
  </FlowDocument>
</FlowDocumentReader>

下圖顯示上述 FlowDocument 呈現方式。

螢幕擷取畫面:FlowDocument LineHeight

下圖顯示相同的 FlowDocument 轉譯方式,其預設設定為 =LineHeightDouble.NaN

螢幕擷取畫面:FlowDocument LineHeight 預設

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

FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));
// Set the content flow direction to left-to-right.
flowDoc.LineHeight = 48;
Dim flowDoc As New FlowDocument(New Paragraph(New Run("A bit of text content...")))
' Set the content flow direction to left-to-right.
flowDoc.LineHeight = 48

備註

變更此值並不會變更相關聯文字的高度;相反地,它會變更包含文字之行的高度。 若要變更文字的大小,請使用 FontSize 屬性。

除了這個屬性之外,中的 FlowDocument 線條配置也會受到其 LineStackingStrategy 屬性的影響。

XAML Attribute Usage

<object LineHeight="double"/>  
- or -  
<object LineHeight="qualifiedDouble"/>  
- or -  
<object LineHeight="Auto"/>  

XAML 值

double
Double

值等於或大於 0.0034 或等於或等於或小於 的字串表示 Double ,則為 160000 。 不合格的值是以裝置獨立圖元來測量。 字串不需要明確包含小數點。

qualifiedDouble
如上所述的 雙精度 浮點數,除了) 後面接著下列其中一個單位規範以外 Auto , (: px 、、 incmpt

px (預設) 是裝置獨立單位 (,每個單位 1/96 英吋)

in 為英吋;1in==96px

cm 為公分;1cm== (96/2.54) px

pt 為點;1pt== (96/72) px

自動
使行高從目前的字型特性自動決定。 相當於 的 Double.NaN 屬性值。

相依性屬性資訊

識別碼欄位 LineHeightProperty
設定為 的中繼資料屬性 true AffectsMeasure, AffectsRender, Inherits

適用於