Hello, today we will learn something that is mostly needed by developers. Windows Phone 8 now allows the developer to use SaveAppointmentTask to help the user. SaveAppointmentTask saves the appointment to the calendar, whereas the task API allows you to populate many of the fields of the new appointment. Use the easy procedure provided here to use very task in your project.
Note:
The example mentioned below is explained using a new project whereas it can easily be embedded in an older project.
Open Visual Studio and create a new Windows Phone 8 project. By using solution explorer open “MainPage.xaml”.
Drag and Drop a button from the toolbox or else create it in XAML code.
- <Button x:Name="Appointment" Margin="103,210,96,194" Content="Appointment"
- Click="Appointment_Click_1" />
- using Microsoft.Phone.Tasks;
- private void Appointment_Click_1(object sender, RoutedEventArgs e)
- {
- }
- SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();
A developer has liberty to set appointment status, details and end time. Developers can even use the option IsAllDayEvent. Besides this it provides other options, like location, remainder, start time and the subject of the appointment.
How can you do it in code? Let me show this to you.
- saveAppointmentTask.Details="Hello, this my first appointment set by using saveAppointmentTask";
- saveAppointmentTask.StartTime = currentTime.AddHours(5);
- saveAppointmentTask.EndTime =
- currentTime.AddHours(8);
- saveAppointmentTask.Subject = "Demo";
- saveAppointmentTask.IsAllDayEvent = false;
- saveAppointmentTask.Reminder = Reminder.FiveMinutes;
- saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;
- saveAppointmentTask.Show();
Use Reminder to set respective time that you choose. You can use different appointment statuses like busy and so on. For that you need to access user data.
This is a simple way to use saveAppointmentTask. You can now run the solution, click on the appointment button you just created.
You’ll see the following,
Using this task will improve the qualities of your application and will beautify it. So why not use it now?
Tips:
Whenever you use SaveAppointmentTask never forget to use date and time and its methods to implement it properly. One can create its object and then use it in the task. It is always better to save the current date and time in a variable of type date time so you might not to again and again type it. One you can do like this:
- DateTime currentTime = DateTime.Now;
Personal Blog: Blend expression.

Saad MahmoodPosted Dec 28, 2014, 11:18 AM
Thank you Mahesh Chand
Mahesh ChandPosted Dec 28, 2014, 11:12 AM
Welcome to C# Corner, Saad.