-api-id | -api-type |
---|---|
T:Microsoft.UI.Xaml.Controls.ImageIconSource |
winrt class |
Represents an icon source that uses an image type as its content. The image types currently supported are .bmp, .gif, .jpg, .png, .wdp, and .tiff.
ImageIconSource is similar to ImageIcon. However, because it is not a FrameworkElement, it can be shared.
Tip
For more info, design guidance, and code examples, see Icons for Windows apps.
[!div class="nextstepaction"] Open the WinUI 3 Gallery app and see IconElement in action
The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub.
The following example shows an AppBarButton with an ImageIconSource. ImageSource specifies an image that's included in the app package.
<!--
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
-->
<AppBarButton >
<AppBarButton.Icon>
<IconSourceElement>
<muxc:ImageIconSource ImageSource="ms-appx:///Assets/globe.png"/>
</IconSourceElement>
</AppBarButton.Icon>
</AppBarButton>
Here we show how to load an ImageIconSource from a bitmap stream.
// using muxc = Microsoft.UI.Xaml.Controls;
var bitmapSource = new BitmapSource();
await bitmapSource.SetSourceAsync(bitmapStream);
var icon = new muxc.ImageIconSource() { ImageSource = bitmapSource };