Skip to main content
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets a brush that describes the foreground color.

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

[BindableAttribute(true)]
public Brush Foreground { get; set; }
public:
[BindableAttribute(true)]
property Brush^ Foreground {
	Brush^ get();
	void set(Brush^ value);
}
[<BindableAttribute(true)>]
member Foreground : Brush with get, set
<BindableAttribute(True)>
Public Property Foreground As Brush

Property Value

Type:

The brush that paints the foreground of the control. The default value is the system dialog font color.

This property only affects a control whose template uses the property as a parameter. On other controls, this property has no impact.

Identifier field

ForegroundProperty

Metadata properties set to true

, ,

The following example shows how to set the font style property of a control.

<Button Name="btn1" Foreground="Black" 
        Click="ChangeForeground">
  Foreground
</Button>
void ChangeForeground(object sender, RoutedEventArgs e)
{
    if (btn1.Foreground == Brushes.Green)
    {
        btn1.Foreground = Brushes.Black;
        btn1.Content = "Foreground";
    }
    else
    {
        btn1.Foreground = Brushes.Green;
        btn1.Content = "Control foreground(text) changes from black to green.";
    }
}
Private Sub ChangeForeground(ByVal Sender As Object, ByVal e As RoutedEventArgs)

    If (Equals(btn1.Foreground, Brushes.Green)) Then

        btn1.Foreground = Brushes.Black
        btn1.Content = "Foreground"

    Else

        btn1.Foreground = Brushes.Green
        btn1.Content = "Control foreground(text) changes from black to green."
    End If
End Sub
.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top