AppNotificationBuilder.SetHeroImage Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
SetHeroImage(Uri) |
Sets the image that is displayed at the top of an app notification, taking up the full width of the notification. |
SetHeroImage(Uri, 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. |
SetHeroImage(Uri)
Sets the image that is displayed at the top of an app notification, taking up the full width of the notification.
public:
virtual AppNotificationBuilder ^ SetHeroImage(Uri ^ imageUri) = SetHeroImage;
/// [Windows.Foundation.Metadata.Overload("SetHeroImage")]
AppNotificationBuilder SetHeroImage(Uri const& imageUri);
[Windows.Foundation.Metadata.Overload("SetHeroImage")]
public AppNotificationBuilder SetHeroImage(System.Uri imageUri);
function setHeroImage(imageUri)
Public Function SetHeroImage (imageUri As Uri) As AppNotificationBuilder
Parameters
Returns
Returns the AppNotificationBuilder instance so that additional method calls can be chained.
- Attributes
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"))
.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>
Remarks
The following screenshot illustrates the placement of the 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.
Applies to
SetHeroImage(Uri, 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.
public:
virtual AppNotificationBuilder ^ SetHeroImage(Uri ^ imageUri, Platform::String ^ alternateText) = SetHeroImage;
/// [Windows.Foundation.Metadata.Overload("SetHeroImage2")]
AppNotificationBuilder SetHeroImage(Uri const& imageUri, winrt::hstring const& alternateText);
[Windows.Foundation.Metadata.Overload("SetHeroImage2")]
public AppNotificationBuilder SetHeroImage(System.Uri imageUri, string alternateText);
function setHeroImage(imageUri, alternateText)
Public Function SetHeroImage (imageUri As Uri, alternateText As String) As AppNotificationBuilder
Parameters
- alternateText
-
String
Platform::String
winrt::hstring
A string containing the alternate text for the hero image.
Returns
Returns the AppNotificationBuilder instance so that additional method calls can be chained.
- Attributes
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>
Remarks
The following screenshot illustrates the placement of the 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.