Share via


AppNotificationButton.SetContextMenuPlacement Method

Definition

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

public:
 virtual AppNotificationButton ^ SetContextMenuPlacement() = SetContextMenuPlacement;
AppNotificationButton SetContextMenuPlacement();
public AppNotificationButton SetContextMenuPlacement();
function setContextMenuPlacement()
Public Function SetContextMenuPlacement () As AppNotificationButton

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 context menu placement for the app notification button.

var notification = new AppNotificationBuilder()
    .AddText("Notification text.")
    .AddButton(new AppNotificationButton("Reply")
        .AddArgument("action", "reply")
        .SetContextMenuPlacement())
    .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' placement='contextMenu'/>
    </actions>
</toast>

Remarks

You can also set the context menu placement value with the AppNotificationButton.ContextMenuPlacement 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