BaselineAlignment 枚举

定义

描述如何相对于已确定的文本基线在垂直轴上为基于文本的元素定位基线。Describes how the baseline for a text-based element is positioned on the vertical axis, relative to the established baseline for text.

public enum class BaselineAlignment
public enum BaselineAlignment
type BaselineAlignment = 
Public Enum BaselineAlignment
继承
BaselineAlignment

字段

Baseline 3

与包含框的实际基线对齐的基线。A baseline that is aligned at the actual baseline of the containing box.

Bottom 2

与包含框的下边缘对齐的基线。A baseline that is aligned at the lower edge of the containing box.

Center 1

与包含框的中心对齐的基线。A baseline that is aligned to the center of the containing box.

Subscript 6

与包含框的下标位置对齐的基线。A baseline that is aligned at the subscript position of the containing box.

Superscript 7

与包含框的上标位置对齐的基线。A baseline that is aligned at the superscript position of the containing box.

TextBottom 5

与文本基线的下边缘对齐的基线。A baseline that is aligned at the lower edge of the text baseline.

TextTop 4

与文本基线的上边缘对齐的基线。A baseline that is aligned at the upper edge of the text baseline.

Top 0

与包含框的上边缘对齐的基线。A baseline that is aligned to the upper edge of the containing box.

示例

下面的示例演示如何使用BaselineAlignment属性来对齐包含框 (在本例中为Paragraph) 中的文本。The following example shows how to use the BaselineAlignment property to align text within a containing box (in this case, a Paragraph).

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <FlowDocumentReader>
    <FlowDocument ColumnWidth="800">
      <Paragraph Background="Blue">

        <!-- The large text forces a large containing box size for the paragraph.
             The smaller text fragments align themselves vertically within this  
             box according to their BaselineAlignment values. -->
        <Span FontSize="40">Baseline:</Span>
        <Span BaselineAlignment="Baseline">Baseline</Span>
        <Span BaselineAlignment="Top">Top</Span>
        <Span BaselineAlignment="Bottom">Bottom</Span>
        <Span BaselineAlignment="Center">Center</Span>
      </Paragraph>
      <Paragraph Background="Green">

        <!-- The BaselineAlignment values of Subscript and Superscript below
             force the containing box to be larger then it normally would be. -->
        <Span FontSize="40">Baseline:</Span>
        <Span BaselineAlignment="Subscript">Subscript</Span>
        <Span BaselineAlignment="Baseline">Baseline</Span>
        <Span BaselineAlignment="Superscript">Superscript</Span>
      </Paragraph>
      <Paragraph Background="Yellow" LineHeight="60" LineStackingStrategy="BlockLineHeight">

        <!-- A deliberate BlockLineHeight stacking strategy change, to show the difference between Top/TextTop 
        and Bottom/TextBottom-->
        <Span FontSize="40" BaselineAlignment="Baseline">Baseline:</Span>
        <Span BaselineAlignment="Top">Top</Span>
        <Span BaselineAlignment="TextTop">TextTop</Span>
        <Span BaselineAlignment="Bottom">Bottom</Span>
        <Span BaselineAlignment="TextBottom">TextBottom</Span>
      </Paragraph>
    </FlowDocument>
  </FlowDocumentReader>
</Page>

下图显示了上述代码的结果。The following illustration shows the result of the code above.

基线对齐Baseline Alignment

适用于

另请参阅