次の方法で共有


TextElement.FontWeight プロパティ

定義

要素のコンテンツの最上位レベルのフォントの太さを取得または設定します。

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

プロパティ値

目的のフォントの太さ。 既定値は、 MessageFontWeight 値によって決まります。

次の例では、FontWeight を例の要素として使用して、Paragraph 属性を設定する方法を示します。

<Paragraph
  FontFamily="Century Gothic, Courier New"  
  FontSize="16pt"
  FontStretch="UltraExpanded"
  FontStyle="Italic"
  FontWeight="DemiBold"
>
  <Run>
    This text will use the Century Gothic font (if available), with fallback to Courier New.  It 
    will render with a font size of 16 points in ultra-expanded demi-bold italic.
  </Run>
</Paragraph>

次の図は、前の例がどのようにレンダリングされるかを示しています。

スクリーンショット: テキスト プロパティが設定されたテキスト

次の例は、FontWeight プロパティをプログラムで設定する方法を示しています。

Run run = new Run(
    "This text will use the Century Gothic font (if available), with fallback to Courier New."
    + "It will render with a font size of 16 pixels in ultra-expanded demi-bold italic.");
Paragraph par = new Paragraph(run);

par.FontFamily = new FontFamily("Century Gothic, Courier New");
par.FontSize = 16;
par.FontStretch = FontStretches.UltraExpanded;
par.FontStyle = FontStyles.Italic;
par.FontWeight = FontWeights.DemiBold;
Dim run As New Run("This text will use the Century Gothic font (if available), with fallback to Courier New." & "It will render with a font size of 16 pixels in ultra-expanded demi-bold italic.")
Dim par As New Paragraph(run)

With par
    .FontFamily = New FontFamily("Century Gothic, Courier New")
    .FontSize = 16
    .FontStretch = FontStretches.UltraExpanded
    .FontStyle = FontStyles.Italic
    .FontWeight = FontWeights.DemiBold
End With

注釈

この依存関係プロパティには、添付プロパティの使用法もあります。 XAML では、使用法は <object TextElement.FontWeight="value".../>です。 ここで、オブジェクトTextElement内に含まれるオブジェクト要素 (通常はフロー要素) であり、 FontWeight 列挙体の文字列形式の値の 1 つです。 コードでは、添付プロパティの使用は、 GetFontWeight メソッドと SetFontWeight メソッドでサポートされています。 添付プロパティの使用方法は一般的ではありません。 TextElement に含めることができるほとんどの要素は、コンテンツ ホストがレンダリングに使用する類似した非アタッチ FontWeight プロパティをサポートしているためです。

依存関係プロパティ情報

品目 価値
識別子フィールド FontWeightProperty
に設定されたメタデータ プロパティ true AffectsMeasureAffectsRenderInherits

適用対象