次の方法で共有


TextDecoration コンストラクター

定義

TextDecoration クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
TextDecoration()

TextDecoration クラスの新しいインスタンスを初期化します。

TextDecoration(TextDecorationLocation, Pen, Double, TextDecorationUnit, TextDecorationUnit)

指定したLocationPenPenOffsetPenOffsetUnit、およびPenThicknessUnit値を使用して、TextDecoration クラスの新しいインスタンスを初期化します。

TextDecoration()

TextDecoration クラスの新しいインスタンスを初期化します。

public:
 TextDecoration();
public TextDecoration();
Public Sub New ()

次のコード例は、パラメーターなしのコンストラクターを使用して TextDecoration を作成する方法を示しています。

// 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>

注釈

Location プロパティの既定値は、Underline です。

適用対象

TextDecoration(TextDecorationLocation, Pen, Double, TextDecorationUnit, TextDecorationUnit)

指定したLocationPenPenOffsetPenOffsetUnit、およびPenThicknessUnit値を使用して、TextDecoration クラスの新しいインスタンスを初期化します。

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)

パラメーター

location
TextDecorationLocation

テキスト装飾の場所。

pen
Pen

Penテキスト装飾の描画に使用されます。 この値が nullの場合、テキスト装飾の色は適用先のテキストの色と一致し、テキスト装飾の太さはフォントの推奨される太さに設定されます。

penOffset
Double

テキスト装飾の位置からの垂直方向の変位。 負の値を指定すると装飾が下に移動し、正の値を指定すると装飾が高くなります。

penOffsetUnit
TextDecorationUnit

penOffsetの値を解釈するために使用される単位。

penThicknessUnit
TextDecorationUnit

penThicknessの値を解釈するために使用される単位。

次のコード例は、locationpenpenOffsetpenOffsetUnit、およびpenThicknessUnitパラメーターを使用してTextDecorationを作成する方法を示しています。

// 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>

適用対象