TextOptions.TextHintingMode Attached Property

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

Gets or sets a value that indicates whether text rendering is optimized for readability or animation.

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

Syntax

'Declaration
See GetTextHintingMode, SetTextHintingMode
See GetTextHintingMode, SetTextHintingMode
<frameworkElement TextOptions.TextHintingMode="Animated"/>
- or -
<frameworkElement TextOptions.TextHintingMode="Fixed"/>

Property Value

Type: System.Windows.Media.TextHintingMode
A value that indicates whether text rendering is optimized for readability or animation.

Remarks

Dependency property identifier field: TextHintingModeProperty

By default, Silverlight optimizes text for readability. Although this is usually desirable, it can have a large performance impact when you animate the scale or rotation of text. This is because changing size or rotation results in recalculating how the glyph is most legible at that font size and position – and an animation changes that size or position 60 times a second.

When animating the rotation or scale of text, you will likely get better performance by turning off this readability optimization. To turn off readability optimization on a per-element basis, set the TextOptions.TextHintingMode attached property on that element to Animated and then set it back to Fixed when the animation ends. In XAML, this could be done as part of a visual state definition in XAML for two different states, each of which set TextOptions.TextHintingMode on an object. In code, you can use the accessor method SetTextHintingMode in code and reference the animated object when the animation starts (set to Animated) and stops (set to Fixed).

Animation that applies to text is not necessarily limited to properties of text elements. The most obvious example of a text property that can benefit from Animated behavior when animated is TextElement.FontSize (or other FontSize properties on specific types). But it might also be beneficial to set Animated behavior whenever any container that contains text animates a property that affects rendering and layout. For example, if you apply a TranslateTransform to a Grid that contains text, that animation may look better if you set TextOptions.TextHintingMode to Animated on that Grid container.

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.