Share via

TextElement.FontSize Property

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

Gets or sets the font size for the content of the element.

Namespace:  System.Windows.Documents
Assembly:  System.Windows (in System.Windows.dll)


Public Property FontSize As Double
public double FontSize { get; set; }
<textElement FontSize="double" ... /> 

Property Value

Type: System.Double
The desired font size in pixels. The default is 11 pixels.


Dependency property identifier field: FontSizeProperty

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 UI definitions from WPF, you must adjust the FontSize attribute values to strip the unit qualifiers, including "px" (this might also involve converting the previous units to pixel values). Otherwise, parsing the XAML will fail.

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 use the default 11 pixel height. (LineStackingStrategy can also influence this spacing.)

Version Information


Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.