-api-id | -api-type |
---|---|
M:Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.SetHeroImage(Windows.Foundation.Uri,System.String) |
winrt method |
Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder.SetHeroImage(Windows.Foundation.Uri,System.String)
Sets the image that is displayed at the top of an app notification, taking up the full width of the notification, with the specified alternate text.
The URI of the hero image file.
A string containing the alternate text for the hero image.
Returns the AppNotificationBuilder instance so that additional method calls can be chained.
The following screenshot illustrates the placement of the hero image.
:::image type="content" source="images/toast-content-hero-image.png" alt-text="A screenshot of an app notification with a hero image.":::
Supported image file types include:
- .png
- .jpg
- .svg
For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.
For reference information about the XML schema for app notifications, see App notification content schema.
The following example demonstrates setting an app logo override image in the XML payload for an app notification.
var notification = new AppNotificationBuilder()
.AddText("Notification text.")
.SetHeroImage(new Uri("ms-appx:///Images/HeroImage.png"), "Alternate text")
.BuildNotification();
AppNotificationManager.Default.Show(notification);
The resulting XML payload:
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Notification text.</text>
<image placement='hero' src='ms-appx:///Images/HeroImage.png'/>
</binding>
</visual>
</toast>