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=" +
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
(Clock picture from “H is for Home on Flickr” Creative Commons)