Skip to content

Latest commit

 

History

History
75 lines (47 loc) · 2.14 KB

appnotificationbuilder_setheroimage_850419990.md

File metadata and controls

75 lines (47 loc) · 2.14 KB
-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)

-description

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.

-parameters

-param imageUri

The URI of the hero image file.

-param alternateText

A string containing the alternate text for the hero image.

-returns

Returns the AppNotificationBuilder instance so that additional method calls can be chained.

-remarks

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.

-see-also

-examples

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>