TextBlock.FontSize Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets the font size for the text content in this element.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<TextBlock FontSize="double" .../>
Property Value
Type: System.DoubleA non-negative value that specifies the font size, measured in pixels. The default is 11.
Dependency property identifier field: FontSizeProperty
FontSize settings for Run child elements override on the containing TextBlock.
For best results, specify integer values for FontSize, even though the property technically accepts floating-point values.
The following XAML example shows how to use the FontSize property to define several text strings that are formatted differently.
<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>
The following illustration shows how the text from the previous example is rendered.
