TextBlock.TextDecorations Egenskap

Definition

Hämtar eller anger en TextDecorationCollection som innehåller de effekter som ska tillämpas på texten i en TextBlock.

public:
 property System::Windows::TextDecorationCollection ^ TextDecorations { System::Windows::TextDecorationCollection ^ get(); void set(System::Windows::TextDecorationCollection ^ value); };
public System.Windows.TextDecorationCollection TextDecorations { get; set; }
member this.TextDecorations : System.Windows.TextDecorationCollection with get, set
Public Property TextDecorations As TextDecorationCollection

Egenskapsvärde

En TextDecorationCollection samling som innehåller textdekorationer som ska tillämpas på det här elementet. Standardvärdet är null (inga textdekorationer används).

Exempel

I följande exempel visas hur du anger attributet TextDecorations .

<TextBlock TextDecorations="Strikethrough">
  This text will render with the strikethrough effect.
</TextBlock>

Följande bild visar hur det här exemplet återges.

Skärmbild: Text med standardgenomstrykningseffekt

Följande siffror visar hur OverLinedekorationerna , Baselinerespektive Underline dekorationer återges.

Skärmbild: Överrad textDecorator

Skärmbild: Standardbaslinjeeffekt på text

Skärmbild: Text med standard understrykningseffekt

I följande exempel visas hur du ställer in TextDecorations-egenskapen programmatiskt.

TextBlock textBlock = new TextBlock(new Run("This text will render with the strikethrough effect."));
textBlock.TextDecorations = TextDecorations.Strikethrough;
Dim textBlock As New TextBlock(New Run("This text will render with the strikethrough effect."))
textBlock.TextDecorations = TextDecorations.Strikethrough

Kommentarer

Ett TextDecoration objekt är en visuell utsmyckning som du kan lägga till i text. Det finns fyra typer av textdekorationer: understrykning, baslinje, genomstrykning och överstreck. Mer information om textdekorationer finns i Så här skapar du en textdekoration.

Som standard är den här egenskapen inställd på null och har ingen TextDecorationCollection associerad med den. Innan du lägger till texteffekter skapar du en ny TextDecorationCollection och tilldelar den till den här egenskapen.

Information om beroendeegenskap

Objekt Value
Identifierarfält TextDecorationsProperty
Metadataegenskaper inställda på true AffectsRender

Gäller för