How can I create a shelltoast?

In my application, I want to notify the user using ShellToast .

Just by running ...

 var toast = new ShellToast { Title = "Nom nom nom!", Content = "More! More! Keep feeding me!", }; toast.Show(); 

... nothing happens, and as I understand it, it needs to be launched from ScheduledTaskAgent . But how do I run this command, and make sure that it runs only once?

+7
source share
2 answers

You cannot use ShellToast while the application is a priority application. It is designed to be called from a background service, while the application is not the primary application.

If you want UX to look like UTX, use the Coding4fun toolkit . ToastPrompt. Here is a code snippet showing how to use it:

  private void ToastWrapWithImgAndTitleClick(object sender, RoutedEventArgs e) { var toast = GetToastWithImgAndTitle(); toast.TextWrapping = TextWrapping.Wrap; toast.Show(); } private static ToastPrompt GetToastWithImgAndTitle() { return new ToastPrompt { Title = "With Image", TextOrientation = System.Windows.Controls.Orientation.Vertical, Message = LongText, ImageSource = new BitmapImage(new Uri("../../ApplicationIcon.png", UriKind.RelativeOrAbsolute)) }; } 

Running this piece of code shows the following:

ToastPrompt control with image

+24
source

Just a small update: using ShellToast , when the application is in the foreground, it is now possible using Windows Phone 8 Update 3. Although they are hidden due to other activities, such as a phone call or a lock screen. A source

0
source

All Articles