FlowDocument.LineHeight 属性

定义

获取或设置每行内容的高度。Gets or sets the height of each line of content.

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

属性值

各行高度均介于 0.0034 到 160000 之间(以与设备无关的像素为单位)。The height of each line, in device independent pixels, in the range 0.0034 to 160000. 如果值为 NaN (等效于属性值 "Auto"),则会使行高由当前字体特征自动确定。A value of NaN (equivalent to an attribute value of "Auto") causes the line height to be determined automatically from the current font characteristics. 默认值为 NaNThe default is NaN.

属性

异常

LineHeight 设置为非正值。LineHeight is set to a non-positive value.

示例

下面的示例演示如何设置 FlowDocument 元素的 LineHeight 特性。The following example shows how to set the LineHeight attribute of a FlowDocument element.

<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 的呈现方式。The following figure shows how the preceding FlowDocument renders.

屏幕快照: FlowDocument LineHeightScreenshot: FlowDocument LineHeight

下图显示了 FlowDocument LineHeight=Double.NaN的默认设置呈现相同的。The following figure shows how the same FlowDocument renders with the default setting of LineHeight=Double.NaN.

屏幕快照: FlowDocument LineHeight 默认值Screenshot: FlowDocument LineHeight default

下面的示例演示如何以编程方式设置 LineHeight 属性。The following example shows how to set the LineHeight property programmatically.

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

注解

更改此值不会更改关联文本的高度;相反,它更改包含文本的行的高度。Changing this value does not change the height of the associated text; rather, it changes the height of the line that contains the text. 若要更改文本大小,请使用 FontSize 属性。To change the size of the text, use the FontSize property.

除了此属性,FlowDocument 中的行布局会受到其 LineStackingStrategy 属性的影响。In addition to this property, the layout of lines in a FlowDocument is affected by its LineStackingStrategy property.

XAML 特性用法XAML Attribute Usage

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

XAML 值XAML Values

双精度double
Double

Double 值的字符串表示形式等于或大于 0.0034,然后 160000String representation of a Double value equal to or greater than 0.0034 and equal to or less then 160000. 非限定值以与设备无关的像素度量。An unqualified value is measured in device independent pixels. 字符串不需要显式包含小数点。Strings need not explicitly include decimal points.

qualifiedDoublequalifiedDouble
如上所述的双精度值(只不过 Auto),后跟以下单元说明符之一: pxincmptA double value as described above, (excepting Auto) followed by one of the following unit specifiers: px, in, cm, pt.

px (默认值)为 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)px (default) is 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)

in 为英寸;1in = = 96pxin is inches; 1in==96px

cm 是厘米;1cm = = (96/2.54) pxcm is centimeters; 1cm==(96/2.54) px

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

自动Auto
使行高由当前字体特征自动确定。Causes the line height to be determined automatically from the current font characteristics. 等效于 Double.NaN的属性值。Equivalent to a property value of Double.NaN.

依赖项属性信息Dependency Property Information

标识符字段Identifier field LineHeightProperty
元数据属性设置为 trueMetadata properties set to true AffectsMeasure中, AffectsRender中, InheritsAffectsMeasure, AffectsRender, Inherits

适用于