ToastNotification.Dismissed Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when a toast notification leaves the screen, either by expiring or being explicitly dismissed by the user. Apps that are running subscribe to this event.
// 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)
Event Type
Examples
The following example shows how to listen for and handle the Dismissed event.
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;
}
}
Remarks
The ToastDismissalReason is included in the ToastDismissedEventArgs parameter.
Applies to
See also
- ToastDismissedEventArgs
- Toast notifications sample
- Sending toast notifications from desktop apps sample
- Toast XML schema
- Tiles, badges, and notifications
- Quickstart: Sending a toast notification
- Quickstart: Sending a toast push notification
- Quickstart: Sending a toast notification from the desktop
- Guidelines and checklist for toast notifications
- How to handle activation from a toast notification
- How to opt in for toast notifications
- How to schedule a toast notification
- How to enable desktop toast notifications through an AppUserModelID
- The toast template catalog
- Toast audio options