Ler em inglês

Compartilhar via


TextDecorationLocation Enumeração

Definição

Especifica a posição vertical de um objeto TextDecoration.

C#
public enum TextDecorationLocation
Herança
TextDecorationLocation

Campos

Nome Valor Description
Baseline 3

A posição vertical de uma linha de base.

OverLine 1

A posição vertical de uma linha sobreposta.

Strikethrough 2

A posição vertical de um tachado.

Underline 0

A posição vertical de um sublinhado. Este é o valor padrão.

Exemplos

O exemplo a seguir cria uma decoração de texto sublinhado e usa um pincel de cor sólida para a caneta.

C#
// 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;
}
XAML
<!-- 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

As decorações de texto estão disponíveis em quatro tipos: linha de base, overline, tachado e sublinhado. O exemplo a seguir mostra os locais das decorações de texto em relação ao texto.

Diagrama de locais de decoração de texto
Tipos de decoração de texto

Aplica-se a

Produto Versões
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9