Yesterday we discussed about the Alarm class and also demonstrated the use of it using a small demo app. Today in this post we will learn about Reminder class and will see the structure of the same. We will also demonstrate the implementation with a small demo.
Like Alarm class, Reminder class is also part of the "Microsoft.Phone.Scheduler" namespace and inherits the same base class. Let's read more about it and explore each and every step to create a simple Windows Phone 7 Reminder application.
Index - Windows Phone 7 (Mango) Tutorial
Know about Reminder Class
Reminder class is part of "Microsoft.Phone.Scheduler" namespace and inherits from ScheduledNotification. We already learned about the base classes yesterday, so will not discuss about them more here. If you didn't yet read the previous chapter, read to learn more about the base classes.
Here is the diagram of the class structure, which will give you better visibility:
In the above diagram, you will come to know a little change between the class "Alarm" and "Reminder". The alarm class exposes two properties called "Sound" and "Title", but here the Reminder class exposes property named "NavigationUri". You can set it to navigate away to a page of your choice.
Create the Basic Application UI
Like previous example, we will create the similar application UI which will have a TextBox to enter the delay time and two buttons to set and reset the reminder. Here is our XAML code for your reference:
<!--ContentPanel - place additional content here-->
<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Orientation="Horizontal" Margin="5" HorizontalAlignment="Center">
<TextBlock Text="Set Time (Sec) : " VerticalAlignment="Center"/>
<TextBox x:Name="txtTime" Width="150"/>
<StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="Center">
<Button Content="Set Reminder" Width="300" Height="70" Click="SetReminder_Click"/>
<Button Content="Reset Reminder" Width="300" Height="70" Click="ResetReminder_Click"/>
Implement the Reminder Feature in Code
This is also similar to the previous example. Instead of creating the Alarm class instance, we will create instance of Reminder and pass the name of the reminder in the constructor. Enter the message that you want to display in the content and assign the BeginTime of the Reminder dialog.
At the end, set the instance to the ScheduledActionService to run the app in the background. Find the code implementation below:
private static void CreateReminder(double time)
var reminder = new Reminder("MyReminder")
Content = "You have a meeting with your team now.",
BeginTime = DateTime.Now.AddSeconds(time)
private static void ResetReminder()
It is require to remove the instance from the service at the end of the operation as shown above. As it is a demo app, we will not handle everything here. Hence, before setting the reminder for the 2nd time onwards, remove it from the service.
It's time to demonstrate our example. Build and run the application. Once the app run and the main UI comes up, it will look similar to the below screenshot:
Enter the time (in seconds) into the TextBox and click "Set Reminder" button. Let us enter 1 sec duration there. Once we click the button, you will see the reminder screen pops up in the screen immediately. You can set any time but the bigger no. you enter, you have to wait for that much time before seeing the Reminder screen.
This will look as shown below in the first figure. You can notice that, unlike the alarm Window this screen has a snooze time settings. You can snooze the reminder for 5 mints, 10 mints, 1 hour, 4 hours or 1 day. Clicking on the snooze box will expand the list as shown in the second screen shown below:
Chose your desired option and click snooze to popup the reminder after specified time of interval. Click dismiss to cancel and close the screen.
Points to Remember
Unlike Alarm window, you can set the Title of the screen here. You can assign the title of the Reminder window as per your need. Have a look into the below code snippet and screenshot for details:
Hope, this chapter was helpful to you to understand the feature. As the reminder process runs in the background, you will notify if you exit the application too.