Control.FontWeight Property

Definition

Gets or sets the weight or thickness of the specified font.

C#
[System.ComponentModel.Bindable(true)]
public System.Windows.FontWeight FontWeight { get; set; }

Property Value

A FontWeight value. The default is Normal.

Attributes

Examples

The following example shows how to set the FontWeight property of a control.

XAML
<Button Name="btn5" FontWeight="Normal" 
        Click="ChangeFontWeight">
  FontWeight
</Button>
C#
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.";
    }
}

Remarks

This property only affects a control whose template uses the FontWeight property as a parameter. On other controls, this property has no impact. For a list of predefined FontWeight values, see the FontWeights class.

Dependency Property Information

Item Value
Identifier field FontWeightProperty
Metadata properties set to true AffectsMeasure, AffectsRender, Inherits

Applies to

Producto Versiones
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9