FontStyle Property

TextElement.FontStyle Property


Gets or sets the font style for the content of the element.

Namespace:   System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)

public FontStyle FontStyle { get; set; }

Property Value

Type: System.Windows.FontStyle

A member of the FontStyles class that specifies the desired font style. The default is determined by the SystemFonts.MessageFontStyle value.

This dependency property also has an usage. In XAML, the usage is <object TextElement.FontStyle="value".../>, where object is an object element (typically a flow element) contained within a TextElement, and value is one of the string-format property names in the FontStyles class. In code, the attached property usage is supported by the GetFontStyle and SetFontStyle methods. The attached property usage is not common, because most elements that can be contained in a TextElement support an analogous nonattached FontStyle property, which the content host uses for rendering.GTMT

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

The following figure shows how the preceding example renders.

Screenshot: Text with text properties set

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

.NET Framework
Available since 3.0
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Return to top
© 2015 Microsoft