다음을 통해 공유


TextDecoration 생성자

정의

TextDecoration 클래스의 새 인스턴스를 초기화합니다.

오버로드

TextDecoration()

TextDecoration 클래스의 새 인스턴스를 초기화합니다.

TextDecoration(TextDecorationLocation, Pen, Double, TextDecorationUnit, TextDecorationUnit)

지정한 TextDecoration, Location, Pen, PenOffsetPenOffsetUnit 값을 사용하여 PenThicknessUnit 클래스의 새 인스턴스를 초기화합니다.

TextDecoration()

TextDecoration 클래스의 새 인스턴스를 초기화합니다.

public:
 TextDecoration();
public TextDecoration ();
Public Sub New ()

예제

다음 코드 예제에서는 매개 변수가 TextDecoration 없는 생성자를 사용하여 만드는 방법을 보여 있습니다.

// 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>

설명

기본값은 Location 속성은 Underline합니다.

적용 대상

TextDecoration(TextDecorationLocation, Pen, Double, TextDecorationUnit, TextDecorationUnit)

지정한 TextDecoration, Location, Pen, PenOffsetPenOffsetUnit 값을 사용하여 PenThicknessUnit 클래스의 새 인스턴스를 초기화합니다.

public:
 TextDecoration(System::Windows::TextDecorationLocation location, System::Windows::Media::Pen ^ pen, double penOffset, System::Windows::TextDecorationUnit penOffsetUnit, System::Windows::TextDecorationUnit penThicknessUnit);
public TextDecoration (System.Windows.TextDecorationLocation location, System.Windows.Media.Pen pen, double penOffset, System.Windows.TextDecorationUnit penOffsetUnit, System.Windows.TextDecorationUnit penThicknessUnit);
new System.Windows.TextDecoration : System.Windows.TextDecorationLocation * System.Windows.Media.Pen * double * System.Windows.TextDecorationUnit * System.Windows.TextDecorationUnit -> System.Windows.TextDecoration
Public Sub New (location As TextDecorationLocation, pen As Pen, penOffset As Double, penOffsetUnit As TextDecorationUnit, penThicknessUnit As TextDecorationUnit)

매개 변수

location
TextDecorationLocation

텍스트 장식의 위치입니다.

pen
Pen

텍스트 장식을 그리는 데 사용되는 Pen입니다. 이 값이 null이면 텍스트 장식 색은 적용되는 텍스트 색과 일치하며 텍스트 장식의 두께는 권장되는 글꼴 두께로 설정됩니다.

penOffset
Double

텍스트 장식의 위치에서 세로 방향으로 이동한 거리입니다. 값이 음수이면 장식이 낮은 쪽으로 이동하고 양수이면 높은 쪽으로 이동합니다.

penOffsetUnit
TextDecorationUnit

penOffset 값을 해석하는 데 사용되는 단위입니다.

penThicknessUnit
TextDecorationUnit

penThickness 값을 해석하는 데 사용되는 단위입니다.

예제

다음 코드 예제에는 만드는 방법을 보여 줍니다는 TextDecoration 를 사용 하 여는 location, pen, penOffsetpenOffsetUnit, 및 penThicknessUnit 매개 변수입니다.

// Use a Maroon pen for the baseline text decoration.
private void SetMaroonBaseline()
{
    // Create an baseline text decoration 2 units lower than the default.
    TextDecoration myBaseline = new TextDecoration(
            TextDecorationLocation.Baseline,
            new Pen(Brushes.Maroon, 1),
            2.0,
            TextDecorationUnit.Pixel,
            TextDecorationUnit.Pixel);

    // Set the baseline decoration to a TextDecorationCollection and add it to the text block.
    TextDecorationCollection myCollection = new TextDecorationCollection();
    myCollection.Add(myBaseline);
    TextBlock2.TextDecorations = myCollection;
}
' Use a Maroon pen for the baseline text decoration.
Private Sub SetMaroonBaseline()
    ' Create an baseline text decoration 2 units lower than the default.
    Dim myBaseline As New TextDecoration(TextDecorationLocation.Baseline, New Pen(Brushes.Maroon, 1), 2.0, TextDecorationUnit.Pixel, TextDecorationUnit.Pixel)

    ' Set the baseline decoration to a TextDecorationCollection and add it to the text block.
    Dim myCollection As New TextDecorationCollection()
    myCollection.Add(myBaseline)
    TextBlock2.TextDecorations = myCollection
End Sub
<TextBlock>
  <TextBlock.TextDecorations>
    <TextDecoration Location="Baseline" PenOffset="2" PenOffsetUnit="Pixel" PenThicknessUnit="Pixel" >
      <TextDecoration.Pen>
        <Pen Brush="Maroon" Thickness="1" />
      </TextDecoration.Pen>
    </TextDecoration>
  </TextBlock.TextDecorations>
  The quick red fox
</TextBlock>

적용 대상