Control.FontWeight Control.FontWeight Control.FontWeight Control.FontWeight Property

定義

取得或設定指定字型的粗細。Gets or sets the weight or thickness of the specified font.

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

屬性值

FontWeight 值。A FontWeight value. 預設為 NormalThe default is Normal.

範例

下列範例示範如何設定FontWeight控制項的屬性。The following example shows how to set the FontWeight property of a control.

<Button Name="btn5" FontWeight="Normal" 
        Click="ChangeFontWeight">
  FontWeight
</Button>
void ChangeFontWeight(object sender, RoutedEventArgs e)
{
    if (btn5.FontWeight == FontWeights.Bold)
    {
        btn5.FontWeight = FontWeights.Normal;
        btn5.Content = "FontWeight";
    }
    else
    {
        btn5.FontWeight = FontWeights.Bold;
        btn5.Content = "Control font weight changes from Normal to Bold.";
    }
}
Private Sub ChangeFontWeight(ByVal Sender As Object, ByVal e As RoutedEventArgs)

    If (btn5.FontWeight = FontWeights.Bold) Then

        btn5.FontWeight = FontWeights.Normal
        btn5.Content = "FontWeight"

    Else

        btn5.FontWeight = FontWeights.Bold
        btn5.Content = "Control font weight changes from Normal to Bold."
    End If
End Sub

備註

這個屬性只會影響的控制項的範本會使用FontWeight屬性做為參數。This property only affects a control whose template uses the FontWeight property as a parameter. 其他控制項,這個屬性會造成任何影響。On other controls, this property has no impact. 取得一份預先定義FontWeight值,請參閱FontWeights類別。For a list of predefined FontWeight values, see the FontWeights class.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field FontWeightProperty
若要設定的中繼資料屬性 trueMetadata properties set to true AffectsMeasure, AffectsRender, InheritsAffectsMeasure, AffectsRender, Inherits

適用於