Control.Foreground 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定描述前景色彩的筆刷。
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
屬性值
繪製控制項前景的筆刷。 預設值為系統對話方塊字型的色彩。
- 屬性
範例
下列範例示範如何設定控制項的字型樣式屬性。
<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
備註
此屬性只會影響範本使用 Foreground 屬性做為參數的控制項。 在其他控制項上,此屬性不會有任何影響。
相依性屬性資訊
識別碼欄位 | ForegroundProperty |
設定為 的中繼資料屬性 true |
AffectsRender, SubPropertiesDoNotAffectRender, Inherits |