TextDecorations Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Innehåller en uppsättning statiska fördefinierade textdekorationer.
public ref class TextDecorations abstract sealed
public static class TextDecorations
type TextDecorations = class
Public Class TextDecorations
- Arv
-
TextDecorations
Exempel
I följande exempel använder en genomstrukna textdekoration standardteckensnittsvärdet.
// 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>
Du kan också ange flera textdekorationer för samma text. I följande exempel används en understrykning och textdekoration över rad för samma text.
<!-- Use both an underline and overline text decoration for the same text. -->
<TextBlock TextDecorations="Underline, Overline">
The quick red fox
</TextBlock>
Du kan använda strängvärdet "Ingen" för att ange att det inte finns några textdekorationer i TextDecorations samlingen. I följande exempel är samlingen TextDecorations inställd på "Ingen".
<!-- Set the text decoration collection to None to indicate no decorations. -->
<TextBlock TextDecorations="None">
The quick red fox
</TextBlock>
Du kan ta bort alla textdekorationer från text med hjälp Clear av metoden . I följande exempel TextDecorations rensas samlingen.
TextBlock2.TextDecorations.Clear();
TextBlock2.TextDecorations.Clear()
Som standard Hyperlink använder ett TextDecoration objekt för att visa en understrykning. Följande markeringsexempel visar ett Hyperlink definierat med och utan understrykning:
<!-- 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>
TextDecoration objekt kan vara prestandaintensiva för att instansiera, särskilt om du har många Hyperlink objekt. Mer information finns i Så här anger du om en hyperlänk är understruken.
Kommentarer
Det finns fyra typer av textdekorationer: baslinje, överlinje, genomstrykning och understrykning. I följande exempel visas platserna för textdekorationerna i förhållande till texten.
XAML-attributanvändning
<object textDecorationsProperty="textDecorationType[,textDecorationType]"/>
XAML-värden
textDecorationType Typ av textdekoration: Baseline, OverLine, Strikethrougheller Underline. Mer än en dekoration tillåts, med värden avgränsade med kommatecken. Du kan också ange "Ingen" för att ange någon typ av textdekoration.
Egenskaper
| Name | Description |
|---|---|
| Baseline |
Anger en baslinje TextDecoration. |
| OverLine |
Anger en överrad TextDecoration. |
| Strikethrough |
Anger en genomstrukning TextDecoration. |
| Underline |
Anger en understrykning TextDecoration. |