AppNotificationButton Class

Definition

Represents a button that is displayed on an app notification.

public ref class AppNotificationButton sealed
/// [Windows.Foundation.Metadata.Activatable(Microsoft.Windows.AppNotifications.Builder.IAppNotificationButtonFactory, 65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class AppNotificationButton final
[Windows.Foundation.Metadata.Activatable(typeof(Microsoft.Windows.AppNotifications.Builder.IAppNotificationButtonFactory), 65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilderContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class AppNotificationButton
function AppNotificationButton(content)
Public NotInheritable Class AppNotificationButton
Inheritance
Object Platform::Object IInspectable AppNotificationButton
Attributes

Examples

The following example demonstrates adding a button to the XML payload for an app notification.

var notification = new AppNotificationBuilder()
    .AddText("Send a message.")
    .AddTextBox("textBox")
    .AddButton(new AppNotificationButton("Send")
        .AddArgument("action", "sendMessage"))
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Send a message.</text>
        </binding>
    </visual>
    <actions>
        <input id='textBox' type='text'/><action content='Send' arguments='action=sendMessage'/>
    </actions>
</toast>

Remarks

Add a button to the XML payload for an app notification by calling AppNotificationBuilder.AddButton. Up to 5 buttons may be added to a single app notification.

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.

Constructors

AppNotificationButton()

Initializes a new instance of the AppNotificationButton class.

AppNotificationButton(String)

Initializes a new instance of the AppNotificationButton class with the specified button text.

Properties

Arguments

Gets or sets the arguments associated with the AppNotificationButton.

ButtonStyle

Gets or sets the style of a button.

Content

Gets or sets the button text for an AppNotificationButton.

ContextMenuPlacement

Gets or sets a value specifying whether the button is displayed inside the app notification context menu.

Icon

Gets or sets the icon for an AppNotificationButton.

InputId

Gets or sets the input ID for an AppNotificationButton.

InvokeUri

Gets or sets the URI that is launched when the app notification button is clicked.

TargetAppId

Gets or sets the Package Family Name (PFN) for the app to be launched when the app notification button is clicked.

ToolTip

Gets or sets the tool-tip text for the app notification button.

Methods

AddArgument(String, String)

Adds an argument composed of a key/value pair to the XML payload for an app notification button.

IsButtonStyleSupported()

Returns a value indicating whether button styles are supported for app notification buttons on the current device.

IsToolTipSupported()

Returns a value indicating whether tool-tips are supported for app notification buttons on the current device.

SetButtonStyle(AppNotificationButtonStyle)

Sets the button style for the app notification button.

SetContextMenuPlacement()

Requests that the app notification button be placed in the context menu of the notification.

SetIcon(Uri)

Sets the icon for an AppNotificationButton.

SetInputId(String)

Sets the input ID for an AppNotificationButton.

SetInvokeUri(Uri)

Sets the URI that is launched when the app notification button is clicked.

SetInvokeUri(Uri, String)

Sets the URI that is launched when the app notification button is clicked, with a provided Package Family Name (PFN) for disambiguation.

SetToolTip(String)

Sets the tool-tip text for the app notification button.

Applies to