Skip to main content
A newer version of this page is available. .

Toast Notification Manager

  • 5 minutes to read

The Toast Notification Manager component introduces toast notifications - a Windows 10 version of traditional alert windows. These notifications display important messages to an end-user by showing small rectangular windows, as the image below shows.

ToastNotifications - ImageAndText02

Note

Toast notifications can only be displayed in Windows 8.0 or higher. For lower Windows versions please use alert windows instead.

A single application can display multiple notifications simultaneously, or one notification multiple times at once. Each notification, presented by the ToastNotification object, can be visualized using one of eight predefined templates that include an image, a bold header string and a regular text string. The notification can also play a specific sound when shown. Follow the steps below to create and customize toast notifications for your application.

  1. Locate the ToastNotificationManager component in your Visual Studio toolbox and drop it onto the form.

    ToastNotifications - Component

  2. Invoke the manager’s smart-tag and click Edit Notifications…

    ToastNotifications - SmartTag and NotificationsDialog

  3. In the dialog shown, click the Add button to add a notification. This will add a ToastNotification object in the manager’s ToastNotificationsManager.Notifications collection. In the property grid to the dialog’s right, you can customize the following notification settings.

  4. To display a specific notification, use the ToastNotificationsManager.ShowNotification method.

    
    toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[3]);
    
  5. After a notification is shown, a number of Toast Notification Manager events can be fired, depending on end-user actions.

    • ToastNotificationsManager.Activated - occurs if an end-user clicks this notification. Handle this event to check which notification was clicked by ID, and perform specific actions depending on the result. The code below illustrates an example.

      
      private void toastNotificationsManager1_Activated(object sender, DevExpress.XtraBars.ToastNotifications.ToastNotificationEventArgs e) {
          switch (e.NotificationID.ToString()) {
              case "3b7fcd8b-a1e0-4ff5-83ce-023cdf6be24b":
                  MessageBox.Show("Notification #1 Clicked");
                  break;
              case "66501f90-ac6b-440d-bf73-483c5ab22143":
                  MessageBox.Show("Notification #2 Clicked");
                  break;
          }
      }
      
    • ToastNotificationsManager.UserCancelled - occurs if an end-user closes the notification.
    • ToastNotificationsManager.TimedOut - occurs when an end-user does not respond to the notification and the notification is hidden after a certain period of idle display. The code below illustrates how to show the timed-out notification again.

      
      private void toastNotificationsManager1_TimedOut(object sender, DevExpress.XtraBars.ToastNotifications.ToastNotificationEventArgs e) {
          toastNotificationsManager1.ShowNotification(e.NotificationID);
      }
      
    • ToastNotificationsManager.Hidden - occurs when a toast notification is hidden via the ToastNotificationsManager.HideNotification or ToastNotificationsManager.HideNotifications method.
    • ToastNotificationsManager.Dropped - fires when a notification is canceled due to end-user system settings.

Notes

There are several Toast Notification Manager specifics that you need to know.

  • To display notifications correctly, the Toast Notifications Manager requires an application shortcut, pinned to the Windows 10 start screen. To create this shortcut while developing your application, set the ToastNotificationsManager.CreateApplicationShortcut property to DefaultBoolean.True. In this case, the application will check whether or not the start screen shortcut already exists. If no shortcut was found, the Toast Notification Manager will create a new shortcut with the specified caption (the ToastNotificationsManager.ApplicationName property) and icon (the ToastNotificationsManager.ApplicationIconPath property).

    ToastNotifications - Create Shortcut

  • You cannot set a notification background manually. The background color is chosen automatically, depending on the application shortcut’s icon color.
  • Notifications are not displayed at the application layer, but at the operating system layer. Thus, displayed notifications can still be visible even after an end-user closes the application.
  • Notifications automatically display a shortcut icon in the bottom right corner. This icon cannot be removed.
  • The number of simultaneously visible notifications depends on the end-user’s system settings.