Skip to main content
.NET Framework Class Library
ControlFontWeight Property

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

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax
<[%$TOPIC/ms592517_en-us_VS_110_1_0_0_0_0%](True)> _
Public Property FontWeight As [%$TOPIC/ms592517_en-us_VS_110_1_0_0_0_1%]
[[%$TOPIC/ms592517_en-us_VS_110_1_0_1_0_0%](true)]
public [%$TOPIC/ms592517_en-us_VS_110_1_0_1_0_1%] FontWeight { get; set; }
[[%$TOPIC/ms592517_en-us_VS_110_1_0_2_0_0%](true)]
public:
property [%$TOPIC/ms592517_en-us_VS_110_1_0_2_0_1%] FontWeight {
	[%$TOPIC/ms592517_en-us_VS_110_1_0_2_0_2%] get ();
	void set ([%$TOPIC/ms592517_en-us_VS_110_1_0_2_0_3%] value);
}
[<[%$TOPIC/ms592517_en-us_VS_110_1_0_3_0_0%](true)>]
member FontWeight : [%$TOPIC/ms592517_en-us_VS_110_1_0_3_0_1%] with get, set
function get FontWeight () : [%$TOPIC/ms592517_en-us_VS_110_1_0_4_0_0%] 
function set FontWeight (value : [%$TOPIC/ms592517_en-us_VS_110_1_0_4_0_1%])
<object FontWeight="[%$TOPIC/ms592517_en-us_VS_110_1_0_5_0_0%]" .../>

Property Value

Type: System.WindowsFontWeight
A FontWeight value. The default is FontWeightsNormal.
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.

Examples

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

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1