TextElement::FontWeight Property


Gets or sets the top-level font weight for the content of the element.

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

property FontWeight FontWeight {
	FontWeight get();
	void set(FontWeight value);

Property Value

Type: System.Windows::FontWeight

A member of the FontWeights class that specifies the desired font weight. The default value is determined by the SystemFonts::MessageFontWeight value.

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

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

  FontFamily="Century Gothic, Courier New"  
    This text will use the Century Gothic font (if available), with fallback to Courier New.  It 
    will render with a font size of 16 points in ultra-expanded demi-bold italic.

The following figure shows how the preceding example renders.

Screenshot: Text with text properties set

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

No code example is currently available or this language may not be supported.

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