Control.Foreground Propriedade

Definição

Recebe ou define um pincel que descreve a cor em primeiro plano.

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; }
[<System.ComponentModel.Bindable(true)>]
member this.Foreground : System.Windows.Media.Brush with get, set
Public Property Foreground As Brush

Valor de Propriedade

O pincel que pinta o primeiro plano do controlo. O valor padrão é a cor da fonte do diálogo do sistema.

Atributos

Exemplos

O exemplo seguinte mostra como definir a propriedade de estilo de fonte de um controlo.

<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

Observações

Esta propriedade afeta apenas um controlo cujo template usa a Foreground propriedade como parâmetro. Noutros controlos, esta propriedade não tem impacto.

Informação de Propriedade de Dependência

Número Value
Campo identificador ForegroundProperty
Propriedades dos metadados definidas como true AffectsRender, SubPropertiesDoNotAffectRender, Inherits

Aplica-se a