Compartilhar via


TextDecoration Construtores

Definição

Inicializa uma nova instância da classe TextDecoration.

Sobrecargas

TextDecoration()

Inicializa uma nova instância da classe TextDecoration.

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

Inicializa uma nova instância da classe TextDecoration com os valores Location, Pen, PenOffset, PenOffsetUnit e PenThicknessUnit.

TextDecoration()

Inicializa uma nova instância da classe TextDecoration.

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

Exemplos

O exemplo de código a seguir mostra como criar um TextDecoration construtor sem parâmetros.

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

Comentários

O valor padrão da Location propriedade é Underline.

Aplica-se a

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

Inicializa uma nova instância da classe TextDecoration com os valores Location, Pen, PenOffset, PenOffsetUnit e 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)

Parâmetros

location
TextDecorationLocation

O local da decoração de texto.

pen
Pen

A Pen usada para desenhar a decoração de texto. Se esse valor for null, a cor da decoração de texto corresponderá à cor do texto à qual ela é aplicada e a espessura da decoração de texto será definida com a espessura recomendada da fonte.

penOffset
Double

O deslocamento vertical do local da decoração de texto. Um valor negativo move a decoração para a parte inferior, enquanto um valor positivo move a decoração para a parte superior.

penOffsetUnit
TextDecorationUnit

As unidades usadas para interpretar o valor do penOffset.

penThicknessUnit
TextDecorationUnit

As unidades usadas para interpretar o valor da Thickness para a pen.

Exemplos

O exemplo de código a seguir mostra como criar um TextDecoration usando os locationparâmetros , pen, penOffsete penThicknessUnit penOffsetUnit,

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

Aplica-se a