Control.Foreground 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一筆筆來描述前景色。
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 ,顏色為 黑色。
備註
每個控制組可能根據其視覺模板以不同方式應用此特性。 此特性僅影響模板以 Foreground 屬性作為參數的控制項。 在其他控制項中,此性質無效。 通常,ContentControl 衍生的控制項會使用 {TemplateBinding} 標記擴充功能,將其 Foreground 值綁定到 ContentPresenter 在控制範本中的前景。 相同的顏色/筆刷也可能用於模板中其他裝飾元素(字形、圖示、控制面)的數值,或用於合成零件屬性,例如時間選擇器控制項中的個別 ComboBox 元素。 欲了解更多關於視覺範本與控制項模板的資訊,請參閱 Styling 控制項 或 範本屬性的 參考頁面。
從 Windows 10 版本 1607(Windows 軟體開發套件(SDK)版本 10.0.14393.0)開始,generic.xaml 包含可用於修改控制項顏色、不同視覺狀態的資源,而無需修改控制範本。 在針對此軟體開發套件(SDK)或更新版本的應用程式中,修改這些資源比設定 背景、前景和 邊框刷子等屬性更為優先。 更多資訊請參閱《造型控制》文章中的輕量級造型章節。