Share via


AppNotificationButton.AddArgument(String, String) Method

Definition

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

public:
 virtual AppNotificationButton ^ AddArgument(Platform::String ^ key, Platform::String ^ value) = AddArgument;
AppNotificationButton AddArgument(winrt::hstring const& key, winrt::hstring const& value);
public AppNotificationButton AddArgument(string key, string value);
function addArgument(key, value)
Public Function AddArgument (key As String, value As String) As AppNotificationButton

Parameters

key
String

Platform::String

winrt::hstring

A string containing the key of the argument.

value
String

Platform::String

winrt::hstring

A string containing the value of the argument.

Returns

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

Examples

The following example shows the usage of this method to add arguments to an app notification button.

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddButton(new AppNotificationButton("Reply")
        .AddArgument("action", "reply"))
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload:

<toast>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
    <actions>
        <action content='Reply' arguments='action=reply'/>
    </actions>
</toast>

Remarks

App notification button arguments added with this method are passed to the activated application when the user clicks on the button. You can add multiple arguments to each button. You can retrieve the arguments added with this method, or add multiple arguments in one call, by accessing the AppNotificationActivatedEventArgs.Arguments property.

For guidance on using the AppNotificationBuilder APIs to create the UI forapp notifications, see App notification content.

For reference information about the XML schema for app notifications, see App notification content schema.

Applies to