FontSize Property
Gets or sets the font size for the content in this element.
XAML |
<object FontSize="Double" .../>
|
Scripting |
value = object.FontSize object.FontSize = value |
Property Value
A non-negative value specifying the desired font size in pixels.
This property is read/write. The default value is 14.666.
Remarks
Note that the font size units in WPF XAML can include a unit qualifier such as "pt" or "px". These unit qualifiers are not supported in Silverlight 1.0, you must use a numeric value only. If you are importing XAML UI definitions from WPF, you might need to adjust the FontSize attribute values to strip the unit qualifiers.
LineBreak is listed in the Applies To list for this property, 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 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 will use the default 14.66 pixel height.
Examples
The following XAML example shows how to use the FontSize property to define several differently-formatted text strings.
XAML |
---|
<!-- Display formatted text as Run objects within a TextBlock. --> <Canvas xmlns="https://schemas.microsoft.com/client/2007"> <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> |
The following illustration shows the rendered formatted text from the previous XAML content example.
TextBlock rendering different font sizes
Applies To
See Also
Text and Fonts Overview
FontFamily
FontStretch
FontStyle
FontWeight