Export (0) Print
Expand All
Expand Minimize

BaselineAlignment Enumeration

Describes how the baseline for a text-based element is positioned on the vertical axis.

Namespace: System.Windows
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public enum BaselineAlignment
public enum BaselineAlignment
public enum BaselineAlignment
<object property="EnumerationValue" .../>

 Member nameDescription
BaselineA baseline that is aligned at the actual baseline of the containing box. 
BottomA baseline that is aligned at the lower edge of the containing box. 
CenterA baseline that is aligned to the center of the containing box. 
SubscriptA baseline that is aligned at the subscript position of the containing box. 
SuperscriptA baseline that is aligned at the superscript position of the containing box. 
TextBottomA baseline that is aligned at the lower edge of the containing box for text. 
TextTopA baseline that is aligned at the upper edge of the containing box for text. 
TopA baseline that is aligned to the upper edge of the containing box. 

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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft