Control.Foreground Właściwość

Definicja

Pobiera lub ustawia pędzel opisujący kolor pierwszego planu.

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

Wartość właściwości

Pędzel, który maluje pierwszy plan kontrolki. Wartość domyślna to kolor czcionki okna dialogowego systemu.

Atrybuty

Przykłady

W poniższym przykładzie pokazano, jak ustawić właściwość stylu czcionki kontrolki.

<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

Uwagi

Ta właściwość ma wpływ tylko na kontrolkę, której szablon używa Foreground właściwości jako parametru. Ta właściwość nie ma wpływu na inne kontrolki.

Informacje dotyczące właściwości zależności

Pole identyfikatora ForegroundProperty
Właściwości metadanych ustawione na true AffectsRender, SubPropertiesDoNotAffectRender, Inherits

Dotyczy