TextDecoration Konstruktorer
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.
Initierar en ny instans av TextDecoration klassen.
Överlagringar
| Name | Description |
|---|---|
| TextDecoration() |
Initierar en ny instans av TextDecoration klassen. |
| TextDecoration(TextDecorationLocation, Pen, Double, TextDecorationUnit, TextDecorationUnit) |
Initierar en ny instans av TextDecoration klassen med de angivna Locationvärdena , Pen, PenOffset, PenOffsetUnitoch PenThicknessUnit . |
TextDecoration()
Initierar en ny instans av TextDecoration klassen.
public:
TextDecoration();
public TextDecoration();
Public Sub New ()
Exempel
I följande kodexempel visas hur du skapar en TextDecoration med hjälp av den parameterlösa konstruktorn.
// 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
Standardvärdet för Location egenskapen är Underline.
Gäller för
TextDecoration(TextDecorationLocation, Pen, Double, TextDecorationUnit, TextDecorationUnit)
Initierar en ny instans av TextDecoration klassen med de angivna Locationvärdena , Pen, PenOffset, PenOffsetUnitoch PenThicknessUnit .
public:
TextDecoration(System::Windows::TextDecorationLocation location, System::Windows::Media::Pen ^ pen, double penOffset, System::Windows::TextDecorationUnit penOffsetUnit, System::Windows::TextDecorationUnit penThicknessUnit);
public TextDecoration(System.Windows.TextDecorationLocation location, System.Windows.Media.Pen pen, double penOffset, System.Windows.TextDecorationUnit penOffsetUnit, System.Windows.TextDecorationUnit penThicknessUnit);
new System.Windows.TextDecoration : System.Windows.TextDecorationLocation * System.Windows.Media.Pen * double * System.Windows.TextDecorationUnit * System.Windows.TextDecorationUnit -> System.Windows.TextDecoration
Public Sub New (location As TextDecorationLocation, pen As Pen, penOffset As Double, penOffsetUnit As TextDecorationUnit, penThicknessUnit As TextDecorationUnit)
Parametrar
- location
- TextDecorationLocation
Platsen för textdekorationen.
- pen
- Pen
Används Pen för att rita textdekorationen. Om det här värdet är nullmatchar textdekorationsfärgen textfärgen som den tillämpas på, och textdekorationens tjocklek är inställd på teckensnittets rekommenderade tjocklek.
- penOffset
- Double
Den lodräta förskjutningen från textdekorationens plats. Ett negativt värde flyttar dekorationen lägre, medan ett positivt värde flyttar dekorationen högre.
- penOffsetUnit
- TextDecorationUnit
De enheter som används för att tolka värdet för penOffset.
- penThicknessUnit
- TextDecorationUnit
De enheter som används för att tolka värdet Thickness för för pen.
Exempel
I följande kodexempel visas hur du skapar en TextDecoration med hjälp av parametrarna location, pen, penOffset, penOffsetUnitoch penThicknessUnit .
// Use a Maroon pen for the baseline text decoration.
private void SetMaroonBaseline()
{
// Create an baseline text decoration 2 units lower than the default.
TextDecoration myBaseline = new TextDecoration(
TextDecorationLocation.Baseline,
new Pen(Brushes.Maroon, 1),
2.0,
TextDecorationUnit.Pixel,
TextDecorationUnit.Pixel);
// Set the baseline decoration to a TextDecorationCollection and add it to the text block.
TextDecorationCollection myCollection = new TextDecorationCollection();
myCollection.Add(myBaseline);
TextBlock2.TextDecorations = myCollection;
}
' Use a Maroon pen for the baseline text decoration.
Private Sub SetMaroonBaseline()
' Create an baseline text decoration 2 units lower than the default.
Dim myBaseline As New TextDecoration(TextDecorationLocation.Baseline, New Pen(Brushes.Maroon, 1), 2.0, TextDecorationUnit.Pixel, TextDecorationUnit.Pixel)
' Set the baseline decoration to a TextDecorationCollection and add it to the text block.
Dim myCollection As New TextDecorationCollection()
myCollection.Add(myBaseline)
TextBlock2.TextDecorations = myCollection
End Sub
<TextBlock>
<TextBlock.TextDecorations>
<TextDecoration Location="Baseline" PenOffset="2" PenOffsetUnit="Pixel" PenThicknessUnit="Pixel" >
<TextDecoration.Pen>
<Pen Brush="Maroon" Thickness="1" />
</TextDecoration.Pen>
</TextDecoration>
</TextBlock.TextDecorations>
The quick red fox
</TextBlock>