Inline.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)

Syntax

'Declaration
Public Property Foreground As Brush
    Get
    Set
'Usage
Dim instance As Inline
Dim value As Brush

value = instance.Foreground

instance.Foreground = value
public Brush Foreground { get; set; }
<inline>
  <inline.Foreground>
    singleBrush
  </inline.Foreground>
</inline>
<inline Foreground="colorString"/>

XAML Values

  • singleBrush
    Within opening and closing property elements for inlines.Foreground, exactly one object element for an object that derives from Brush. The object element is generally one of the following Silverlight classes: ImageBrush, LinearGradientBrush, RadialGradientBrush, SolidColorBrush, or VideoBrush.

  • colorString
    The Color for a SolidColorBrush expressed as an attribute string. This can be a named color, an RGB value, or an ScRGB value. RGB or ScRGB may also specify alpha information. See Color.

Property Value

Type: System.Windows.Media.Brush
The brush that is applied to the text contents. The default is a SolidColorBrush with Color value Black.

Remarks

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 inlines. If you use a non-solid brush, you might instead make a resource reference to a ResourceDictionary defined brush.

Version Information

Silverlight

Supported in: 3

Silverlight for Windows Phone

Supported in: 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.

See Also

Reference

Inline Class

System.Windows.Documents Namespace

FontFamily

FontSize

FontStretch

FontStyle

FontWeight

Other Resources

Text and Fonts