Control.Foreground Propriété
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit un pinceau qui décrit la couleur du premier plan.
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
Le pinceau qui peint le premier plan du contrôle. La valeur par défaut est la couleur de la police des boîtes de dialogue du système.
- Attributs
L’exemple suivant montre comment définir la propriété de style de police d’un contrôle.
<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
Cette propriété affecte uniquement un contrôle dont le modèle utilise la Foreground propriété comme paramètre. Sur les autres contrôles, cette propriété n’a aucun impact.
Champ Identificateur | ForegroundProperty |
Propriétés de métadonnées définies sur true |
AffectsRender, SubPropertiesDoNotAffectRender, Inherits |
Produit | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
Commentaires sur .NET
.NET est un projet open source. Sélectionnez un lien pour fournir des commentaires :