BaselineAlignment 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
描述如何相对于已确定的文本基线在垂直轴上为基于文本的元素定位基线。
public enum class BaselineAlignment
C#
public enum BaselineAlignment
type BaselineAlignment =
Public Enum BaselineAlignment
- 继承
Baseline | 3 | 与包含框的实际基线对齐的基线。 |
Bottom | 2 | 与包含框的下边缘对齐的基线。 |
Center | 1 | 与包含框的中心对齐的基线。 |
Subscript | 6 | 与包含框的下标位置对齐的基线。 |
Superscript | 7 | 与包含框的上标位置对齐的基线。 |
TextBottom | 5 | 与文本基线的下边缘对齐的基线。 |
TextTop | 4 | 与文本基线的上边缘对齐的基线。 |
Top | 0 | 与包含框的上边缘对齐的基线。 |
以下示例演示如何使用 BaselineAlignment 属性在包含框中对齐文本,在本例 Paragraph 中为) (。
XAML
<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>
下图显示了上述代码的结果。
产品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
Windows Desktop | 3.0, 3.1, 5, 6, 7 |