Skip to main content
.NET Framework Class Library
ControlFontFamily Property

Gets or sets the font family of the control.

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/ms592513_en-us_VS_110_1_0_0_0_0%](True)> _
<[%$TOPIC/ms592513_en-us_VS_110_1_0_0_0_1%]([%$TOPIC/ms592513_en-us_VS_110_1_0_0_0_2%].Font)> _
Public Property FontFamily As [%$TOPIC/ms592513_en-us_VS_110_1_0_0_0_3%]
[[%$TOPIC/ms592513_en-us_VS_110_1_0_1_0_0%](true)]
[[%$TOPIC/ms592513_en-us_VS_110_1_0_1_0_1%]([%$TOPIC/ms592513_en-us_VS_110_1_0_1_0_2%].Font)]
public [%$TOPIC/ms592513_en-us_VS_110_1_0_1_0_3%] FontFamily { get; set; }
[[%$TOPIC/ms592513_en-us_VS_110_1_0_2_0_0%](true)]
[[%$TOPIC/ms592513_en-us_VS_110_1_0_2_0_1%]([%$TOPIC/ms592513_en-us_VS_110_1_0_2_0_2%]::Font)]
public:
property [%$TOPIC/ms592513_en-us_VS_110_1_0_2_0_3%]^ FontFamily {
	[%$TOPIC/ms592513_en-us_VS_110_1_0_2_0_4%]^ get ();
	void set ([%$TOPIC/ms592513_en-us_VS_110_1_0_2_0_5%]^ value);
}
[<[%$TOPIC/ms592513_en-us_VS_110_1_0_3_0_0%](true)>]
[<[%$TOPIC/ms592513_en-us_VS_110_1_0_3_0_1%]([%$TOPIC/ms592513_en-us_VS_110_1_0_3_0_2%].Font)>]
member FontFamily : [%$TOPIC/ms592513_en-us_VS_110_1_0_3_0_3%] with get, set
<object>
  <object.FontFamily>
    <[%$TOPIC/ms592513_en-us_VS_110_1_0_4_0_0%] .../>
  </object.FontFamily>
</object>
<object FontFamily="[%$TOPIC/ms592513_en-us_VS_110_1_0_5_0_0%]" .../>

Property Value

Type: System.Windows.MediaFontFamily
A font family. The default is the system dialog font.
Remarks

This property only affects a control whose template uses the FontFamily property as a parameter. On other controls, this property has no impact.

Examples

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

<Button Name="btn2" FontFamily="Arial" 
        Click="ChangeFontFamily">
  FontFamily
</Button>
Private Sub ChangeFontFamily(ByVal Sender As Object, ByVal e As RoutedEventArgs)

    ffamily = btn2.FontFamily
    str = ffamily.ToString()
    If (str = ("Arial Black")) Then

        btn2.FontFamily = New FontFamily("Arial")
        btn2.Content = "FontFamily" 

    Else

        btn2.FontFamily = New FontFamily("Arial Black")
        btn2.Content = "Control font family changes from Arial to Arial Black." 

    End If 
End Sub
void ChangeFontFamily(object sender, RoutedEventArgs e)
{

    ffamily = btn2.FontFamily;
    str = ffamily.ToString();
    if (str == ("Arial Black"))
    {
        btn2.FontFamily = new FontFamily("Arial");
        btn2.Content = "FontFamily";
    }
    else
    {
        btn2.FontFamily = new FontFamily("Arial Black");
        btn2.Content = "Control font family changes from Arial to Arial Black.";

    }
}
Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.