TextDecorationLocation Enum
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.
Anger objektets lodräta position TextDecoration .
public enum class TextDecorationLocation
public enum TextDecorationLocation
type TextDecorationLocation =
Public Enum TextDecorationLocation
- Arv
Fält
| Name | Värde | Description |
|---|---|---|
| Underline | 0 | Den lodräta positionen för en understrykning. Det här är standardvärdet. |
| OverLine | 1 | Den lodräta positionen för en överlinje. |
| Strikethrough | 2 | Den lodräta positionen för en genomstrykning. |
| Baseline | 3 | Den lodräta positionen för en baslinje. |
Exempel
I följande exempel skapas en understrykning av textdekorationen och en pensel med en fast färg används för pennan.
// 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>
Kommentarer
Textdekorationer finns i fyra typer: baslinje, överlinje, genomstrykning och understrykning. I följande exempel visas platserna för textdekorationerna i förhållande till texten.
Textdekorationstyper