private void Queue_Click(object sender, RoutedEventArgs e) { // Use a helper method to check whether I can send a toast. // Note: If this check wasn't here, the code would fail silently. if (MySampleHelper.CanSendToasts()) { // Send multiple toasts to action center for (int i = 0; i < numberToastsToSend; i++) { // Use a helper method to create a new ToastNotification. ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 3", String.Format("message {0}", toastIndex)); // Set SuppressPopup = true on the toast in order to send it directly to action center without // producing a popup on the user's phone. toast.SuppressPopup = true; // Send the toast. ToastNotificationManager.CreateToastNotifier().Show(toast); toastIndex++; } // Tell the user that the toast was sent successfully. // This can be ommitted in a real app. MySampleHelper.ShowSuccessMessage(String.Format("We sent {0} toasts to action center.\nThe last 20 notifications will be shown in action center, followed by a \"More Notifications\" message to indicate that the app sent more toasts than are shown.", numberToastsToSend)); } }
private void DisplayToast_Click(object sender, RoutedEventArgs e) { // Use a helper method to check whether I can send a toast. // Note: If this check wasn't here, the code would fail silently. if (MySampleHelper.CanSendToasts()) { // Use a helper method to create a new ToastNotification. // Each time we run this code, we'll append the count (toastIndex in this example) to the message // so that it can be seen as a unique message in the action center. This is not mandatory - we // do it here for educational purposes. ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 1", String.Format("message {0}", toastIndex)); // Optional. Setting an expiration time on a toast notification defines the maximum // time the notification will be displayed in action center before it expires and is removed. // If this property is not set, the notification expires after 7 days and is removed. // Tapping on a toast in action center launches the app and removes it immediately from action center. toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(3600); // Display the toast. ToastNotificationManager.CreateToastNotifier().Show(toast); toastIndex++; // Tell the user that the toast was sent successfully. // This can be ommitted in a real app. MySampleHelper.ShowSuccessMessage(); } }
private void DisplayToast_Click(object sender, RoutedEventArgs e) { // Use a helper method to check whether I can send a toast. // Note: If this check wasn't here, the code would fail silently. if (MySampleHelper.CanSendToasts()) { // Use a helper method to create a new ToastNotification. ToastNotification toast = MySampleHelper.CreateTextOnlyToast("Scenario 2", String.Format("message {0}", toastIndex)); // Set SuppressPopup = true on the toast in order to send it directly to action center without // producing a popup on the user's phone. toast.SuppressPopup = true; // Send the toast. ToastNotificationManager.CreateToastNotifier().Show(toast); toastIndex++; // Tell the user that the toast was sent successfully. // This can be ommitted in a real app. MySampleHelper.ShowSuccessMessage(); } }