Share via


IXRTextElement::SetForeground (Compact 2013)

3/28/2014

This method sets the brush that paints the text in this text element.

Syntax

virtual HRESULT STDMETHODCALLTYPE SetForeground(
    __in IXRBrush* pForeground
) = 0;

Parameters

  • pForeground
    [in] Pointer to an object derived from IXRBrush that paints the text in the text element.

Return Value

Returns an HRESULT that indicates success or failure.

Returns XR_E_INVALID_OBJECT if pForeground is not a XAML for Windows Embedded object.

Remarks

The value of pForeground specifies the brush for the displayed text. A brush can represent a solid color, a linear or radial gradient, or an image.

When you animate the foreground text in Microsoft Silverlight 3 XAML, you must use indirect targeting syntax. For example, to animate the color of a SolidColorBrush control that is the foreground of a TextBlock control, you could use the following:

<ColorAnimation ... Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" />.

For more information about how to set the foreground brush in Silverlight 3 XAML, see the Microsoft Silverlight 3 documentation.

To use a specific interface pointer type, you can use the helper template version of this method that XAML for Windows Embedded provides. When you supply a derived type, this version automatically supplies a type-safe method that implicitly converts the returned type from a generic interface, so you do not have to explicitly call QueryInterface to convert the generic interface into the required object type.

.NET Framework Equivalent

System.Windows.Documents.TextElement.Foreground

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRTextElement
IXRTextElement::GetForeground