AppNotificationButton.SetContextMenuPlacement 方法

定义

请求将应用通知按钮放置在通知的上下文菜单中。

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

返回

返回 AppNotificationButton 实例,以便可以链接其他方法调用。

示例

以下示例演示如何使用此方法设置应用通知按钮的上下文菜单位置。

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

AppNotificationManager.Default.Show(notification);

如果支持紧急方案,则为生成的 XML 有效负载:

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

注解

还可以使用 AppNotificationButton.ContextMenuPlacement 属性设置上下文菜单放置值。

有关使用 AppNotificationBuilder API 创建应用通知 UI 的指导,请参阅 应用通知内容

有关应用通知的 XML 架构的参考信息,请参阅 应用通知内容架构

适用于