ToastPrompt

Overview

Basically ToastPrompt is an UI component that derives from the toolkit`s abstract PopUp<string, PopUpResult> class . As its name says it is a kind of extended popup that performs toast like notification: when a background process (such as an async download) has completed notifies the user.


Getting Started

To begin using ToastPrompt first add a reference to the Coding4Fun.Phone.Controls.dll assembly.

Creating ToastPrompt :

C#:
    ToastPrompt toast = new ToastPrompt();
    toast.Title = "ToastPrompt";
    toast.Message = "Some message";
    toast.ImageSource = new BitmapImage(new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute));
     
    toast.Completed += toast_Completed;
    toast.Show();

void toast_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)
{
     //add some code here
}

Key Features

ToastPrompt exposes the following properties that can be used to customize its content:
  • MillisecondsUntilHidden,
  • IsTimerEnabled
  • Title
  • Message
  • ImageSource
  • TextOrientation
  • Overlay
  • HasGesturesDisabled

NOTE: What is the HasGesturesDisabled property? : With the current Gesture Service in the Silverlight Toolkit (Feb 2011 release), if two controls are overlapped and the bottom control has a listener attached, events will still bubble through with no way to cancel it without putting on a listener. In a control that is called PopUp, it is self defeating to have this bubble through effect happening. If the SL toolkit corrects the behavior, we’ll remove the HasGesturesDisabled property as it would no longer be needed. This would also remove the dependency on the Silverlight Toolkit.
You can show ToastPrompt using its Show() method.
When the ToastPrompt popup is closed the Completed event is fired.

Example1:
var toast = new ToastPrompt
    {
        Title = "Simple usage",
        Message = "Message",
        ImageSource = new BitmapImage(new Uri("..\\ApplicationIcon.png", UriKind.RelativeOrAbsolute))
    };



Example2:
     SolidColorBrush gray = new SolidColorBrush(Colors.LightGray);
     SolidColorBrush orange = new SolidColorBrush(Color.FromArgb(200, 255, 117, 24));
      
    ToastPrompt toast = new ToastPrompt
    {
        Background = gray,
        Foreground = orange,
        Title = "Customized",
        Message = "Custom colors",
        FontSize = 30,
        TextOrientation = System.Windows.Controls.Orientation.Vertical,
        ImageSource = new BitmapImage(new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute))
    };
    toast.Completed += toast_Completed;
    toast.Show()



Example3:
    ToastPrompt toast = new ToastPrompt();
    toast.Title = "Vertical";
    toast.Message = "Vertical text message";
    toast.FontSize = 40;
    toast.TextOrientation = System.Windows.Controls.Orientation.Vertical;
    toast.ImageSource = new BitmapImage(new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute));
 
    toast.Show();



Example4:
    ToastPrompt toast = new ToastPrompt();
    toast.FontSize = 30;
    toast.Title = "Horizontal";
    toast.Message = "Horizontal text";
    toast.TextOrientation = System.Windows.Controls.Orientation.Horizontal;
    toast.ImageSource = new BitmapImage(new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute));
 
    toast.Show();


Last edited May 3, 2011 at 8:58 AM by WinPhoneGeek, version 2

Comments

No comments yet.