Windows Dev Center

TextBlock.FontSize Property

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.

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

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

Show:
© 2015 Microsoft