Control.Foreground Property

Definition

Gets or sets a brush that describes the foreground color.

C#
public Brush Foreground { get; set; }
XAML
<control Foreground="{StaticResource resourceName}"/>
- or -
<control Foreground="colorString"/>
- or -
<control>
  <control.Foreground>singleBrush</control.Foreground>
</control>

Property Value

The brush that paints the foreground of the control. The default value is a SolidColorBrush with color of Black.

Remarks

Each control might apply this property differently based on its visual template. This property only affects a control whose template uses the Foreground property as a parameter. On other controls, this property has no effect. Typically, a ContentControl derived control uses a {TemplateBinding} markup extension to bind its Foreground value to the Foreground of a ContentPresenter within the control template. The same color/brush might also be used for values of other decorative elements in the template (glyphs, icons, control surfaces) or to composite part properties such as the individual ComboBox elements of the TimePicker control. For more info about visual templates and control templating, see Styling controls or the reference page for the Template property.

Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background, Foreground, and BorderBrush. For more info, see the Light-weight styling section of the XAML styles article.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also