Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 2.97 KB

iconelement_foreground.md

File metadata and controls

54 lines (37 loc) · 2.97 KB
-api-id -api-type
P:Windows.UI.Xaml.Controls.IconElement.Foreground
winrt property

Windows.UI.Xaml.Controls.IconElement.Foreground

-description

Gets or sets a brush that describes the foreground color.

-xaml-syntax

<icon Foreground="{StaticResource resourceName}"/>
- or -
<icon Foreground="colorString"/>

-xaml-values

resourceName
resourceNameThe resource name (x:Key attribute value) of an existing XAML resource that defines a brush. This is the recommended way to specify Brush values in XAML if you have any intention of using the same colors or brushes in more than one part of your UI. See Remarks in Brush or ResourceDictionary and XAML resource references.
colorString
colorStringThe Color for a SolidColorBrush expressed as an attribute string. This can be a named color, an RGB value, or an ScRGB value. RGB or ScRGB may also specify alpha information. See the XAML Values section in Color.
## -property-value The brush that paints the foreground of the control. The default is **null**, (a null brush) which is evaluated as [Transparent](../windows.ui/colors_transparent.md) for rendering. However, this value is typically set by a default system resource at runtime, which is tied to the active theme and other settings.

-remarks

You can set the Foreground property on the AppBarButton or on an IconElement derived icon. If you set the Foreground on the AppBarButton, it's applied only to the default visual state. It's not applied to the other visual states defined in the AppBarButton template, like MouseOver. If you set the Foreground on the IconElement derived icon, the color is applied to all visual states.

The only valid Brush type for the Foreground value is SolidColorBrush. If you attempt to use a brush that's not declaring a solid color, the value is ignored at run time and replaced with a SolidColorBrush that is white or black, depending on the current theme.

Foreground replaces the color information from a BitmapIcon.UriSource source file. Any non-transparent pixel in the source image is replaced with the Foreground color.

-examples

This example shows an AppBarButton that uses a SymbolIcon with its Foreground set to "Green".

<AppBarButton Label="Accept">
    <AppBarButton.Icon>
        <SymbolIcon Symbol="Accept" Foreground="Green"/>
    </AppBarButton.Icon>
</AppBarButton>

-see-also

BitmapIcon.UriSource, SymbolIcon, Adding app bars, Use brushes