Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 BaselineAlignment Enumeration
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
BaselineAlignment Enumeration

Updated: November 2007

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

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

Visual Basic (Declaration)
Public Enumeration BaselineAlignment
Visual Basic (Usage)
Dim instance As BaselineAlignment
C#
public enum BaselineAlignment
Visual C++
public enum class BaselineAlignment
J#
public enum BaselineAlignment
JScript
public enum BaselineAlignment
XAML Attribute Usage
<object property="enumerationValue" .../>
Member nameDescription
Top A baseline that is aligned to the upper edge of the containing box.
Center A baseline that is aligned to the center of the containing box.
Bottom A baseline that is aligned at the lower edge of the containing box.
Baseline A baseline that is aligned at the actual baseline of the containing box.
TextTop A baseline that is aligned at the upper edge of the text baseline.
TextBottom A baseline that is aligned at the lower edge of the text baseline.
Subscript A baseline that is aligned at the subscript position of the containing box.
Superscript A baseline that is aligned at the superscript position 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).

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>

The following illustration shows the result of the code above.

Baseline Alignment

Windows Vista

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker