Control.Foreground Tulajdonság

Definíció

Lekéri vagy beállítja az előtérszínt leíró ecsetet.

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

Tulajdonság értéke

Az ecset, amely a vezérlő előterét festi. Az alapértelmezett érték a rendszer párbeszédpaneljének betűszíne.

Attribútumok

Példák

Az alábbi példa bemutatja, hogyan állíthatja be egy vezérlőelem betűstílus-tulajdonságát.

<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

Megjegyzések

Ez a tulajdonság csak azt a vezérlőt érinti, amelynek sablonja paraméterként használja a Foreground tulajdonságot. Más vezérlők esetében ez a tulajdonság nincs hatással.

Függőségi tulajdonság adatai

Termék Érték
Azonosító mező ForegroundProperty
Metaadat-tulajdonságok beállítása: true \, \, \

A következőre érvényes: