FontSize Property

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

<object FontSize="Double" .../>
value = object.FontSize
object.FontSize = value

Property Value


A non-negative value specifying the desired font size in pixels.

This property is read/write. The default value is 14.666.


Note that the font size units in WPF XAML can include a unit qualifier such as "pt" or "px". These unit qualifiers are not supported in Silverlight 1.0, you must use a numeric value only. If you are importing XAML UI definitions from WPF, you might need to adjust the FontSize attribute values to strip the unit qualifiers.

LineBreak is listed in the Applies To list for this property, because it does exist in the object model and you can get and set it. However, all LineBreak properties are ignored for rendering purposes. In particular, changing FontSize does not affect the height of the line break. Only the FontSize set on the text runs themselves has any effect. The line height for a LineBreak is influenced by the surrounding runs, but multiple line breaks in succession will use the default 14.66 pixel height.


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

<!-- Display formatted text as Run objects within a TextBlock. -->
  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 the rendered formatted text from the previous XAML content example.

TextBlock rendering different font sizes

TextBlock rendering different font sizes

Applies To

LineBreak, Run, TextBlock

See Also

Text and Fonts Overview