TextElement::FontSize Property
Gets or sets the font size for the content of the element.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
[TypeConverterAttribute(typeof(FontSizeConverter))] [LocalizabilityAttribute(LocalizationCategory::None)] public: property double FontSize { double get (); void set (double value); }
<object FontSize="double"/> - or - <object FontSize="qualifiedDouble"/>
XAML Values
Property Value
Type: System::DoubleThe 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 |
|---|---|
| ArgumentException | 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.
The following example shows how to set the FontSize attribute, using Paragraph as the example element.
<Paragraph FontFamily="Century Gothic, Courier New" FontSize="16pt" FontStretch="UltraExpanded" FontStyle="Italic" FontWeight="DemiBold" > <Run> This text will use the Century Gothic font (if available), with fallback to Courier New. It will render with a font size of 16 points in ultra-expanded demi-bold italic. </Run> </Paragraph>
The following figure shows how the preceding example renders.

The following example shows how to set the FontSize property programmatically.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.