Control.Foreground Property

Definition

Obtiene o establece un pincel que describe el color de primer plano.Gets or sets a brush that describes the foreground color.

public:
 property System::Windows::Media::Brush ^ Foreground { System::Windows::Media::Brush ^ get(); void set(System::Windows::Media::Brush ^ value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.Media.Brush Foreground { get; set; }
member this.Foreground : System.Windows.Media.Brush with get, set
Public Property Foreground As Brush

Property Value

Brush

El pincel que pinta el primer plano del control.The brush that paints the foreground of the control. El valor predeterminado es el color de la fuente del diálogo del sistema.The default value is the system dialog font color.

Attributes

Examples

En el ejemplo siguiente se muestra cómo establecer la propiedad de estilo de fuente de un control.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

Remarks

Esta propiedad solo afecta a un control cuya plantilla usa la propiedad Foreground como un parámetro.This property only affects a control whose template uses the Foreground property as a parameter. En otros controles, esta propiedad no tiene ningún impacto.On other controls, this property has no impact.

Información sobre propiedades de dependenciaDependency Property Information

Campo de identificadorIdentifier field ForegroundProperty
Propiedades de metadatos establecidas en trueMetadata properties set to true AffectsRender, SubPropertiesDoNotAffectRender, InheritsAffectsRender, SubPropertiesDoNotAffectRender, Inherits

Applies to