BitmapIcon
BitmapIcon
BitmapIcon
BitmapIcon
Class
Definition
Represents an icon that uses a bitmap as its content.
public : class BitmapIcon : IconElement, IBitmapIcon, IBitmapIcon2public class BitmapIcon : IconElement, IBitmapIcon, IBitmapIcon2Public Class BitmapIcon Inherits IconElement Implements IBitmapIcon, IBitmapIcon2// This API is not available in Javascript.
<BitmapIcon .../>
- Inheritance
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Inherited Members
Inherited properties
Inherited events
Inherited methods
Examples
This example shows an AppBarButton with a BitmapIcon. The UriSource specifies an image that's included in the app package.
<AppBarButton Label="BitmapIcon" Click="AppBarButton_Click">
<AppBarButton.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/globe.png"/>
</AppBarButton.Icon>
</AppBarButton>
Remarks
To use a BitmapIcon as the Icon for an AppBarButton, you specify the URI of an image file.
The file that you use should be a solid image on a transparent background. The bitmap image as retrieved from the UriSource location is expected to be a true bitmap that has transparent pixels and non-transparent pixels. The recommended format is PNG. Other file-format image sources will load apparently without error but result in a solid block of the foreground color inside the AppBarButton.
All color info is stripped from the bitmap when the BitmapIcon renders in an AppBarButton. The remaining non-transparent colors are combined to produce an image that's entirely the foreground color as set by the Foreground property (this typically comes from styles or templates, such as the default template resolving to a theme resource).
You typically specify a UriSource value that references a bitmap that you've included as part of the app, as a resource or otherwise within the app package. For more info on the ms-appx: scheme and other URI schemes that you can use to reference resources in your app, see Uri schemes.
Note
You can set the Foreground property on the AppBarButton or on the BitmapIcon. 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 BitmapIcon, the color is applied to all visual states.
Constructors
BitmapIcon() BitmapIcon() BitmapIcon() BitmapIcon()
Initializes a new instance of the BitmapIcon class.
public : BitmapIcon()public BitmapIcon()Public Sub New()// This API is not available in Javascript.
Properties
ShowAsMonochrome ShowAsMonochrome ShowAsMonochrome ShowAsMonochrome
Gets or sets a value that indicates whether the bitmap is shown in a single color.
public : PlatForm::Boolean ShowAsMonochrome { get; set; }public bool ShowAsMonochrome { get; set; }Public ReadWrite Property ShowAsMonochrome As bool// This API is not available in Javascript.
<BitmapIcon ShowAsMonochrome="bool"/>
- Value
- PlatForm::Boolean bool bool bool
true to show the bitmap in a single color; false to show the bitmap in full color. The default is true.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
ShowAsMonochromeProperty ShowAsMonochromeProperty ShowAsMonochromeProperty ShowAsMonochromeProperty
Identifies the ShowAsMonochrome dependency property.
public : static DependencyProperty ShowAsMonochromeProperty { get; }public static DependencyProperty ShowAsMonochromeProperty { get; }Public Static ReadOnly Property ShowAsMonochromeProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the ShowAsMonochrome dependency property.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
UriSource UriSource UriSource UriSource
Gets or sets the Uniform Resource Identifier (URI) of the bitmap to use as the icon content.
public : Uri UriSource { get; set; }public Uri UriSource { get; set; }Public ReadWrite Property UriSource As Uri// This API is not available in Javascript.
<BitmapIcon UriSource="uriString"/>
- See Also
UriSourceProperty UriSourceProperty UriSourceProperty UriSourceProperty
Identifies the UriSource dependency property.
public : static DependencyProperty UriSourceProperty { get; }public static DependencyProperty UriSourceProperty { get; }Public Static ReadOnly Property UriSourceProperty As DependencyProperty// This API is not available in Javascript.
The identifier for the UriSource dependency property.