Windows Dev Center

The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TextElement.FontSize Property


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

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

public double FontSize { get; set; }

Property Value

Type: System.Double

The desired font size to use in device independent pixels, greater than 0.001 and less than or equal to 35791. The default depends on current system settings and depends on the SystemFonts.MessageFontSize value.

Exception Condition

FontSize is set to a value greater than 35791 or less than or equal to 0.001.

This dependency property also has an attached property usage. In XAML, the usage is <object TextElement.FontSize="value".../>, where object is an object element (typically a flow element) contained within a TextElement, and value is one of the string-format values as explained in XAML Values. In code, the attached property usage is supported by the GetFontSize and SetFontSize methods. The attached property usage is not common, because most elements that can be contained in a TextElement support an analogous nonattached FontSize property, which the content host uses for rendering.

<object FontSize="double"/>
- or -
<object FontSize="qualifiedDouble"/>



String representation of a Double value equal to or greater than 0.0 but smaller than PositiveInfinity. An unqualified value is measured in device independent pixels. Strings need not explicitly include decimal points.


A double value as described above, followed by one of the following unit specifiers: px, in, cm, pt.

px (default) is device-independent units (1/96th inch per unit)

in is inches; 1in==96px

cm is centimeters; 1cm==(96/2.54) px

pt is points; 1pt==(96/72) px

The following example shows how to set the FontSize attribute, using Paragraph as the example element.

The following figure shows how the preceding example renders.

Screenshot: Text with text properties set

The following example shows how to set the FontSize property programmatically.

.NET Framework
Available since 3.0
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Return to top
© 2015 Microsoft