Control.Foreground 屬性

定義

取得或設定描述前景色彩的筆刷。

public:
 property Brush ^ Foreground { Brush ^ get(); void set(Brush ^ value); };
Brush Foreground();

void Foreground(Brush value);
public Brush Foreground { get; set; }
var brush = control.foreground;
control.foreground = brush;
Public Property Foreground As Brush
<control Foreground="{StaticResource resourceName}"/>
- or -
<control Foreground="colorString"/>
- or -
<control>
  <control.Foreground>singleBrush</control.Foreground>
</control>

屬性值

繪製控制項前景的筆刷。 默認值為 SolidColorBrush ,色彩為 Black

備註

每個控件可能會根據其視覺範本以不同的方式套用此屬性。 此屬性只會影響範本使用Foreground屬性做為參數的控件。 在其他控件上,這個屬性沒有任何作用。 一般而言, ContentControl 衍生控件會使用 {TemplateBinding} 標記延伸 ,將其 Foreground 值系結至控件範本內 ContentPresenter 的前景。 相同的色彩/筆刷也可用於範本中其他裝飾元素的值, (圖像、圖示、控件介面) 或複合元件屬性,例如 TimePicker 控件的個別 ComboBox 元素。 如需可視化範本和控件範本化的詳細資訊,請參閱 設定控件的樣式範本 屬性的參考頁面。

從 Windows 10 1607 版 1607 (Windows 軟體開發套件 (SDK) 10.0.14393.0 版) 開始,generic.xaml 包含可用來修改不同視覺狀態中控件色彩的資源,而不需修改控件範本。 在以此軟體開發工具包為目標的應用程式 (SDK) 或更新版本中,最好修改這些資源來設定屬性,例如 Background、Foreground 和 BorderBrush。 如需詳細資訊,請參閱設定控件樣式一文的輕量型樣式一節。

適用於

另請參閱