Building a Reminder Application in Windows Phone Mango
published on: 9/19/2011 | Views: N/A | Tags: WP7Toolkit
by Nguyen Pham
Introduction
Reminder is currently in the Namespace Microsoft.Phone.Scheduler, sometime it can remind us some of work.
Idea of this Apps is very simply that you have a to do task, and when on time these Reminder will remind you !
In this article I'll talk about a Reminder Application in Windows Phone Mango.
Fundamental
The first step, We're creating Windows Phone Application Project
Next, we right-click to References -> choose Add Refrences ->choose Microsoft.Phone.Controls.Toolkit :
Then we go to MainPage.xaml and build a sample User Interface but after that we declare
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
To use the Control from the toolkit.
The second step, We go to Mainpage.xaml and built a sample UI include TimePicker, DatePicker, Button and TextBox for Reminder, like that:
Following XAML Code :
<phone:PhoneApplicationPage
x:Class="ReminderApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Reminder App" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="200"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="82*" />
</Grid.RowDefinitions>
<TextBlock Text="Date" Grid.Row="0" Margin="14,0,0,0"/>
<TextBlock Text="Time" Grid.Row="2" Margin="14,0,0,0"/>
<TextBlock Text="To Do" Grid.Row="4" Margin="14,0,0,0"/>
<toolkit:DatePicker Grid.Row="1" Name="dpkDate" />
<toolkit:TimePicker Grid.Row="3" Name="tpkTime" />
<Button Content="Save" Grid.Row="7" Height="72" HorizontalAlignment="Left" Margin="293,4,0,0" Name="btnSave" VerticalAlignment="Top" Width="160" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
The Finally, We coding for Reminder App in MainPage.xaml.cs.
Full C# Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Scheduler;
namespace ReminderApp
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
this.btnSave.Click += btnSave_Click;
}
void btnSave_Click(object sender, RoutedEventArgs e)
{
DateTime _Date = dpkDate.Value.Value;
TimeSpan _Time = tpkTime.Value.Value.TimeOfDay;
_Date = _Date.Date + _Time;
String _Content = txtContent.Text;
if (_Date < DateTime.Now)
MessageBox.Show("Your time is not match !\nPlease Enter again !");
else if (String.IsNullOrEmpty(_Content))
MessageBox.Show("Your task can't be empty !\n Please enter to do task !");
else
{
ScheduledAction _OldReminder = ScheduledActionService.Find("TodoReminder"); if (_OldReminder != null)
ScheduledActionService.Remove(_OldReminder.Name);
Reminder _Reminder = new Reminder("TodoReminder")
{
BeginTime = _Date,
Title = "Reminder",
Content = _Content,
};
ScheduledActionService.Add(_Reminder);
MessageBox.Show("Set Reminder Completed");
}
}
}
}
It's Remind on time :
I hope this useful . Thanks for reading !
/*It's time for Windows Phone*/
You can also follow us on Twitter @winphonegeek
|
|
About the author: |
Comments
Grt
posted by: Govind on 9/20/2011 8:43:47 PM
Nice post..This code works fine..My reminder is set. But I can get the reminder back in my emulator..Is it like we get the reminder only in device but not in emulator ?
How to make apps with no coding
posted by: Vlad on 9/21/2011 2:40:07 PM
Hi!your article is great!I use snappii.com to create apps with no programming skills and in some minutes.That is difficult to believe in but it's true.
I will add reminder to a app
posted by: dony on 9/28/2011 8:10:47 AM
I will add reminder to a app.thanks your greate article.
Superb!
posted by: Rajeev Nair on 10/17/2011 10:12:19 PM
Nice article. Will jump on to it right now! :)
Doubt
posted by: Anusha Atluri on 12/5/2011 6:10:44 PM
When we give the details and press save it navigates to some other page for which code is already written. This page seems to have two AppBar icons. they are appearing as two crosses in circles. How to i set proper images to these icons?
Our Top Articles & Free books
- Our FREE e-book: "Windows Phone Toolkit In Depth" 2nd edition
- 400+ Windows Phone Development articles in our Article Index
- 21 WP7 Toolkit in Depth articles covering all controls
- 12 WP7 Coding4Fun Toolkit in Depth articles covering all controls
- Performance Tips when creating WP7 apps
- Creating a WP7 Custom Control in 7 Steps
- WP7 working with VisualStates: How to make a ToggleSwitch from CheckBox
- What makes a WP7 App successful
- Creating theme friendly UI in WP7 using OpacityMask
- Implementing Windows Phone 7 DataTemplateSelector and CustomDataTemplateSelector
- All about Splash Screens in WP7 – Creating animated Splash Screen
- Getting Started with Unit Testing in Silverlight for WP7
- WP7 WatermarkedTextBox custom control
Our Top Tips & Samples
- All about WP7 Isolated Storage series
- WP7 Dynamically Generating DataTemplate in code
- 5 tips for a successful WP7 Marketplace submission
- WP7: Navigating to a page in different assembly
- WP7 ContextMenu: answers to popular questions
- WP7 ListBox: answers to popular questions
- WP7 working with Images: Content vs Resource build action
- WP7 Element Binding samples
- WP7 working with XML: reading, filtering and databinding
- Drawing in WP7: #2 Drawing shapes with finger
- WP7 TextBox Light theme problems - the solution
- Changing the WP7 Panorama Background Image dynamically with Animation

