通过


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

下图显示了与默认设置LineHeight=Double.NaN相同的FlowDocument呈现方式。

屏幕截图: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 属性用法

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

XAML 值

Double

一个 Double 值等于或大于 0.0034 或等于或等于或小于或小于 160000的字符串表示形式。 不限定的值以与设备无关的像素进行度量。 字符串不需要显式包含小数点。

qualifiedDouble如上所述的双精度值(除外Auto)后跟以下单位说明符之一:px、、incmpt

px (默认值) 是独立于设备的单位(每单位 1/96 英寸)

in 为英寸;1in==96px

cm 为厘米;1cm==(96/2.54) px

pt is points;1pt==(96/72) px

自动使行高从当前字体特征自动确定。 等效于属性值为 Double.NaN.

Dependency 属性信息

物品 价值
标识符字段 LineHeightProperty
元数据属性设置为 true AffectsMeasureAffectsRenderInherits

适用于