Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Property Value

Type: Double

A non-negative value that specifies the desired font size, in pixels.

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


In Windows Presentation Foundation (WPF), the XAML values for FontSize can include a unit qualifier such as "pt" or "px". However, these unit qualifiers are not supported in Silverlight. You must specify a numeric value only, which is always interpreted as pixels. If you are importing XAML user interface definitions from WPF, you might have to adjust the FontSize attribute values to strip the unit qualifiers, or convert the units.

The "Applies To" section of this topic lists LineBreak, 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 setting on the text runs 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 text strings that are formatted differently.

<!-- 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>


Applies To



PasswordBox (Silverlight 2)


TextBox (Silverlight 2)