Export (0) Print
Expand All

TextElement.FontSize Property

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

Namespace: System.Windows.Documents
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None)] 
[TypeConverterAttribute(typeof(FontSizeConverter))] 
public double FontSize { get; set; }
/** @property */
public double get_FontSize ()

/** @property */
public void set_FontSize (double value)

public function get FontSize () : double

public function set FontSize (value : double)

<object FontSize="double"/>
- or -
<object FontSize="qualifiedDouble"/>
 double  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.  qualifiedDouble  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 

Property Value

A double value specifying the desired font size to use in points (1 point = 1/72 of an inch = 96/72 device independent pixels). The font size must be less than or equal to 35791 and greater than 0.001. The default font size depends on current system settings, and is derived from the MessageFontSize metric.

Exception typeCondition

ArgumentException

Raised when an attempt is made to set the font size to a value greater than 35791 or less than or equal to 0.001.

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

<Paragraph
  FontFamily="Century Gothic, Courier New"  
  FontSize="16"
  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 this example renders.

Screenshot: Text with text properties set

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

Run run = new 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.");
Paragraph par = new Paragraph(run);

par.FontFamily = new FontFamily("Century Gothic, Courier New");
par.FontSize = 16;
par.FontStretch = FontStretches.UltraExpanded;
par.FontStyle = FontStyles.Italic;
par.FontWeight = FontWeights.DemiBold;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft