Export (0) Print
Expand All
Key
M11
M12
M21
M22
Tag
Uri
X1
X2
Y1
Y2
Expand Minimize

FontSize

Silverlight

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

<object FontSize="Double"  .../>
value = object.FontSize
object.FontSize = 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. -->
<Canvas
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">

<TextBlock
  FontFamily="Arial" Width="400" Text="Sample text formatting runs">
  <LineBreak/>
  <Run Foreground="Maroon" FontFamily="Courier New" FontSize="24">Courier New 24</Run>
  <LineBreak/>
  <Run Foreground="Teal" FontFamily="Times New Roman" FontSize="18" FontStyle="Italic">Times New Roman Italic 18</Run>
  <LineBreak/>
  <Run Foreground="SteelBlue" FontFamily="Verdana" FontSize="14" FontWeight="Bold">Verdana Bold 14</Run>
</TextBlock>

</Canvas>

LineBreak

Run

PasswordBox (Silverlight 2)

TextBlock

TextBox (Silverlight 2)

Community Additions

ADD
Show:
© 2015 Microsoft