TextDecorations Clase

Definición

Proporciona un conjunto de decoraciones de texto predefinidas estáticas.

public ref class TextDecorations abstract sealed
public static class TextDecorations
type TextDecorations = class
Public Class TextDecorations
Herencia
TextDecorations

Ejemplos

En el ejemplo siguiente, una decoración de texto tachado usa el valor de fuente predeterminado.

// Use the default font values for the strikethrough text decoration.
private void SetDefaultStrikethrough()
{
    // Set the underline decoration directly to the text block.
    TextBlock1.TextDecorations = TextDecorations.Strikethrough;
}
' Use the default font values for the strikethrough text decoration.
Private Sub SetDefaultStrikethrough()
    ' Set the underline decoration directly to the text block.
    TextBlock1.TextDecorations = TextDecorations.Strikethrough
End Sub
<!-- Use the default font values for the strikethrough text decoration. -->
<TextBlock
  TextDecorations="Strikethrough"
  FontSize="36" >
  The quick red fox
</TextBlock>

También puede especificar varias decoraciones de texto para el mismo texto. En el ejemplo siguiente, se usa una decoración de texto de subrayado y sobrelínea para el mismo texto.

<!-- Use both an underline and overline text decoration for the same text. -->
<TextBlock TextDecorations="Underline, Overline">
  The quick red fox
</TextBlock>

Puede usar el valor de cadena "None" para indicar que no hay decoraciones de texto en la TextDecorations colección. En el ejemplo siguiente, la TextDecorations colección se establece en "None".

<!-- Set the text decoration collection to None to indicate no decorations. -->
<TextBlock TextDecorations="None">
  The quick red fox
</TextBlock>

Puede quitar todas las decoraciones de texto del texto mediante el Clear método . En el ejemplo siguiente, se borra la TextDecorations colección.

TextBlock2.TextDecorations.Clear();
TextBlock2.TextDecorations.Clear()

De forma predeterminada, Hyperlink usa un objeto TextDecoration para mostrar un subrayado. En el ejemplo de marcado siguiente se muestra un elemento Hyperlink definido con y sin subrayado:

<!-- Hyperlink with default underline. -->
<Hyperlink NavigateUri="http://www.msn.com">
  MSN Home
</Hyperlink>

<Run Text=" | " />

<!-- Hyperlink with no underline. -->
<Hyperlink Name="myHyperlink" TextDecorations="None"
           MouseEnter="OnMouseEnter"
           MouseLeave="OnMouseLeave"
           NavigateUri="http://www.msn.com">
  My MSN
</Hyperlink>

Los objetos TextDecoration pueden ser intensivos en el rendimiento para crear instancias, especialmente si tiene muchos objetos Hyperlink. Para obtener más información, vea Cómo: Especificar si un hipervínculo está subrayado.

Comentarios

Hay cuatro tipos de decoraciones de texto: línea base, sobrelínea, tachado y subrayado. En el ejemplo siguiente se muestran las ubicaciones de las decoraciones de texto relativas al texto.

Diagrama de ubicaciones de decoración de texto Diagrama
Ejemplo de tipos de decoración de texto

Uso de atributos XAML

<object textDecorationsProperty="textDecorationType[,textDecorationType]"/>  

Valores XAML

textDecorationType
Tipo de decoración de texto: Baseline, OverLine, Strikethrougho Underline. Se permite más de una decoración, con valores separados por comas. También puede especificar "None" para indicar ningún tipo de decoración de texto.

Propiedades

Baseline

Especifica una clase TextDecoration de línea base.

OverLine

Especifica una clase TextDecoration de línea alta.

Strikethrough

Especifica una clase TextDecoration tachada.

Underline

Especifica una clase TextDecoration subrayada.

Se aplica a