TextBlock.FontSource Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the font source that is applied to the text for rendering content.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property FontSource As FontSource
public FontSource FontSource { get; set; }

Property Value

Type: System.Windows.Documents.FontSource
The font source that is used to render content in the text box. The default is nulla null reference (Nothing in Visual Basic).

Remarks

For the TextBlock element, Silverlight selects the font from the following sources:

  • From supported local fonts.

  • From the fonts that are provided in a packaged file that is referenced in the FontFamily property.

  • From the zip or .ttf file passed as a stream to the FontSource property.

The font that is selected is the best match based on the values of the FontFamily, FontStretch, FontStyle, and FontWeight properties. It is important to specify all four of these font properties to make sure that an accurate and consistent font selection is made for the TextBlock.

If the FontSource property is set to nulla null reference (Nothing in Visual Basic), any assigned custom font is cleared and the TextBlock renders with the default font.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.