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

适用于