Control.Foreground Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a brush that describes the foreground color.
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
Property Value
The brush that paints the foreground of the control. The default value is the system dialog font color.
- Attributes
Examples
The following example shows how to set the font style property of a control.
<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
Remarks
This property only affects a control whose template uses the Foreground property as a parameter. On other controls, this property has no impact.
Dependency Property Information
Identifier field | ForegroundProperty |
Metadata properties set to true |
AffectsRender, SubPropertiesDoNotAffectRender, Inherits |
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET