ToastNotification.Dismissed 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当 Toast 通知离开屏幕时发生,该通知即将过期或被用户显式消除。 正在运行的应用订阅此事件。
// Register
event_token Dismissed(TypedEventHandler<ToastNotification, ToastDismissedEventArgs const&> const& handler) const;
// Revoke with event_token
void Dismissed(event_token const* cookie) const;
// Revoke with event_revoker
ToastNotification::Dismissed_revoker Dismissed(auto_revoke_t, TypedEventHandler<ToastNotification, ToastDismissedEventArgs const&> const& handler) const;
public event TypedEventHandler<ToastNotification,ToastDismissedEventArgs> Dismissed;
function onDismissed(eventArgs) { /* Your code */ }
toastNotification.addEventListener("dismissed", onDismissed);
toastNotification.removeEventListener("dismissed", onDismissed);
- or -
toastNotification.ondismissed = onDismissed;
Public Custom Event Dismissed As TypedEventHandler(Of ToastNotification, ToastDismissedEventArgs)
事件类型
示例
以下示例演示如何侦听和处理 Dismissed 事件。
var notifications = Windows.UI.Notifications;
yourToastNotification.addEventListener("dismissed", function (e) {
switch (e.reason) {
case notifications.ToastDismissalReason.applicationHidden:
// The application hid the toast using ToastNotifier.hide.
break;
case notifications.ToastDismissalReason.userCanceled:
// The user dismissed the toast.
break;
case notifications.ToastDismissalReason.timedOut:
// The toast has expired.
break;
}
}
注解
ToastDismissalReason 包含在 ToastDismissedEventArgs 参数中。