AppNotificationButton.SetIcon(Uri) Method

Definition

Sets the icon for an AppNotificationButton.

public:
 virtual AppNotificationButton ^ SetIcon(Uri ^ value) = SetIcon;
AppNotificationButton SetIcon(Uri const& value);
public AppNotificationButton SetIcon(System.Uri value);
function setIcon(value)
Public Function SetIcon (value As Uri) As AppNotificationButton

Parameters

value
Uri Uri

The URI of the button icon.

Returns

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

Examples

The following example demonstrates the use of this method to set the icon for the app notification button.

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddButton(new AppNotificationButton("Reply")
        .AddArgument("action", "reply")
        .SetIcon(new Uri("ms-appx:///Images/Reply.png")))
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload if the urgent scenario is supported:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <actions>
        <action content='Reply' arguments='action=reply' imageUri='ms-appx:///Images/Reply.png'/>
    </actions>
</toast>

Remarks

You can also set the icon for an app notification button with the AppNotificationButton.Icon.

The following screenshot illustrates an app notification button that uses an icon.

A screenshot of an app notification with buttons that use icons.

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