FontSize Property

TextBlock.FontSize Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the font size for the text content in this element.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public double FontSize { get; set; }
<TextBlock FontSize="double" .../>

Property Value

Type: System.Double
A non-negative value that specifies the font size, measured in pixels. The default is 11.

Dependency property identifier field: FontSizeProperty

FontSize settings for Run child elements override on the containing TextBlock.

For best results, specify integer values for FontSize, even though the property technically accepts floating-point values.

The following XAML example shows how to use the FontSize property to define several text strings that are formatted differently.

  FontFamily="Arial" Width="400" Text="Sample text formatting runs">
  <Run Foreground="Maroon" FontFamily="Courier New" 
     FontSize="24">Courier New 24</Run>
  <Run Foreground="Teal" FontFamily="Times New Roman" 
     FontSize="18" FontStyle="Italic">Times New Roman Italic 18</Run>
  <Run Foreground="SteelBlue" FontFamily="Verdana" FontSize="14" 
     FontWeight="Bold">Verdana Bold 14</Run>

The following illustration shows how the text from the previous example is rendered.

A TextBlock that is rendering different font sizes

Sample of text formatting runs.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2018 Microsoft