TextElement.Foreground Property
Gets or sets the Brush to apply to the content in this element.
Namespace: System.Windows.Documents
Assembly: System.Windows (in System.Windows.dll)
<textElement> <textElement.Foreground> singleBrush </textElement.Foreground> </textElement>
<textElement Foreground="colorString"/>
XAML Values
Property Value
Type: System.Windows.Media.BrushThe brush that is applied to the text contents. The default is a SolidColorBrush with Color value Black.
Dependency property identifier field: ForegroundProperty
The Foreground property specifies a Brush for the rendered text. A Brush can represent a solid color, a linear or radial gradient, or an image.
Some brush types (SolidColorBrush) support a XAML attribute syntax, whereas other brush types (ImageBrush, LinearGradientBrush, and RadialGradientBrush) support only an object element syntax. This is why two versions of XAML syntax are shown for this property.
When animating a Foreground, you must use indirect targeting. For instance, if you are animating the color of a SolidColorBrush that is the Foreground of a TextBlock, the syntax would be <ColorAnimation ... Storyboard.TargetProperty="(Run.Foreground).(SolidColorBrush.Color)" />.
XAML property element usage for a non-solid brush is uncommon, because it clashes with the inherent document object model intention for text elements. If you use a non-solid brush, you might instead make a resource reference to a ResourceDictionary defined brush.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.