TextDecorationLocation 列舉

定義

指定 TextDecoration 物件的垂直位置。

public enum class TextDecorationLocation
public enum TextDecorationLocation
type TextDecorationLocation = 
Public Enum TextDecorationLocation
繼承
TextDecorationLocation

欄位

Baseline 3

基準線的垂直位置。

OverLine 1

頂線的垂直位置。

Strikethrough 2

刪除線的垂直位置。

Underline 0

底線的垂直位置。 這是預設值。

範例

下列範例會建立底線文字裝飾,並使用畫筆的純色筆刷。

// Use a Red pen for the underline text decoration.
private void SetRedUnderline()
{
    // Create an underline text decoration. Default is underline.
    TextDecoration myUnderline = new TextDecoration();

    // Create a solid color brush pen for the text decoration.
    myUnderline.Pen = new Pen(Brushes.Red, 1);
    myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;

    // Set the underline decoration to a TextDecorationCollection and add it to the text block.
    TextDecorationCollection myCollection = new TextDecorationCollection();
    myCollection.Add(myUnderline);
    TextBlock2.TextDecorations = myCollection;
}
' Use a Red pen for the underline text decoration.
Private Sub SetRedUnderline()
    ' Create an underline text decoration. Default is underline.
    Dim myUnderline As New TextDecoration()

    ' Create a solid color brush pen for the text decoration.
    myUnderline.Pen = New Pen(Brushes.Red, 1)
    myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended

    ' Set the underline decoration to a TextDecorationCollection and add it to the text block.
    Dim myCollection As New TextDecorationCollection()
    myCollection.Add(myUnderline)
    TextBlock2.TextDecorations = myCollection
End Sub
<!-- Use a Red pen for the underline text decoration -->
<TextBlock
  FontSize="36" >
  jumps over
  <TextBlock.TextDecorations>
    <TextDecorationCollection>
      <TextDecoration 
        PenThicknessUnit="FontRecommended">
        <TextDecoration.Pen>
          <Pen Brush="Red" Thickness="1" />
        </TextDecoration.Pen>
      </TextDecoration>
    </TextDecorationCollection>
  </TextBlock.TextDecorations>
</TextBlock>

備註

文字裝飾有四種類型:基準、超線、刪除線和底線。 下列範例顯示文字裝飾相對於文字的位置。

文字裝飾位置圖表
文字裝飾類型

適用於