Over a million developers have joined DZone.

Windows Phone Alerts and Reminders

DZone's Guide to

Windows Phone Alerts and Reminders

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

Another great feature for Windows Phone Mango is the ability to set up reminders and alerts in your application (While it is not running).  You would be surprised how many applications want/need this. During our Windows Phone 7 Unleashed events this was a recurring topic. 

The great part is that it is really simple.


For this application, we are creating a very basic interface.  A text box for the title, a text box for the reminder message and a button that says “remind me”.  In addition, there is a label to hold the parameter that is sent back from the reminder.

The first thing you want to do once you build the UI is to click on the Remind Me button to create the click event for the button and add the following code to the event.

 private void OnRemindMeClick(object sender, RoutedEventArgs e)
            Reminder r = new Reminder("reminder");
            r.Title = txtTitle.Text;
            r.Content = txtContent.Text;
            r.BeginTime = DateTime.Now.AddSeconds(10);
            r.NavigationUri = new Uri("/MainPage.xaml?reminder=" + txtContent.Text ,UriKind.Relative);

All we need to do is :

  • create an instance of the reminder
  • Set the title and content to the text boxes text property
  • set the begin time (in this instance I am doing it in 10 seconds from now)
  • Set the NavigationUri (this is where you will return when a user clicks on a message)
  • Add the reminder to the ScheduledActionService

Notice that we are passing the txtContent.Text back to the program when the user replies.  This can be userIDs, itemIDs, etc… .  Whatever makes sense for your program.

To capture the returning data, add this to an onNavigatedTo override.

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
            string param = null;
            if (NavigationContext.QueryString.TryGetValue("reminder", out param))
                Param.Text = param;

            if (ScheduledActionService.Find("reminder") != null)


We collect the reminder parameter from the Querystring and set it equal to our Param.txt . Notice that we are also removing the reminder from the service.  In the way ours is constructed, if the user clicked on it a second time it would try to add “reminder” a second time which is not allowed.

There you go…. easy as pie Smile

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.


Published at DZone with permission of Daniel Egan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}