Condividi tramite


Control.Foreground Proprietà

Definizione

Ottiene o imposta un pennello che descrive il colore di primo piano.

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

Valore della proprietà

Pennello che disegna il primo piano del controllo. Il valore predefinito è il colore del carattere della finestra di dialogo di sistema.

Attributi

Esempio

Nell'esempio seguente viene illustrato come impostare la proprietà stile del carattere di un controllo .

<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

Commenti

Questa proprietà influisce solo su un controllo il cui modello utilizza la Foreground proprietà come parametro. In altri controlli questa proprietà non ha alcun impatto.

Informazioni sulle proprietà di dipendenza

Elemento Valore
Campo Identificatore ForegroundProperty
Proprietà dei metadati impostate su true AffectsRender, SubPropertiesDoNotAffectRender, Inherits

Si applica a