IconElement.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 = iconElement.foreground;
iconElement.foreground = brush;
Public Property Foreground As Brush
<icon Foreground="{StaticResource resourceName}"/>
- or -
<icon Foreground="colorString"/>
屬性值
那個畫筆,描繪了控制畫面前景。 預設為 null(空筆刷),渲染時會被評估為 透明 。 然而,這個值通常由執行時的預設系統資源設定,該資源與活動主題及其他設定綁定。
範例
這個範例展示了一個使用 SymbolIcon 並將前景設為「綠色」的 AppBarButton。
<AppBarButton Label="Accept">
<AppBarButton.Icon>
<SymbolIcon Symbol="Accept" Foreground="Green"/>
</AppBarButton.Icon>
</AppBarButton>
備註
你可以在 AppBarButton 或 IconElement 衍生的圖示上設定 Foreground 屬性。 如果你在 AppBarButton 上設定前景,它只會套用到預設的視覺狀態。 它不會套用到 AppBarButton 範本中定義的其他視覺狀態,例如 MouseOver。 如果你把 Foreground 設定在 IconElement 衍生的圖示上,顏色會套用到所有視覺狀態。
Foreground 值唯一有效的 筆刷 類型是 SolidColorBrush。 如果你嘗試使用未宣告純色的筆刷,執行時該值會被忽略,取而代之的是根據當前主題呈現的白色或黑色 SolidColorBrush 。
前景取代了 BitmapIcon.UriSource 原始檔案中的顏色資訊。 來源影像中任何非透明像素都會被前景色取代。