Control.FontWeight 属性

定义

获取或设置指定字体的粗细。

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; }
[<System.ComponentModel.Bindable(true)>]
member this.FontWeight : System.Windows.FontWeight with get, set
Public Property FontWeight As FontWeight

属性值

FontWeight

一个 FontWeight 值。 默认值为 Normal

属性

示例

以下示例演示如何设置 FontWeight 控件的属性。

<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 属性作为参数的控件。 在其他控件上,此属性没有影响。 有关预定义 FontWeight 值的列表,请参阅 FontWeights 类。

依赖项属性信息

标识符字段 FontWeightProperty
元数据属性设置为 true AffectsMeasure, AffectsRender, Inherits

适用于