,

Saving an Appointment Using the SaveAppointmentTask

New to Windows Phone 8 is the SaveAppointmentTask, which allows you to save an appointment via the phone’s built-in Calendar app.

SaveAppointmentTask contains various optional properties that allow you to prepopulate the appointment UI in the Calendar app when the task is shown. The following example demonstrates how to create a new appointment.

SaveAppointmentTask task = new SaveAppointmentTask
    {
        AppointmentStatus = AppointmentStatus.Busy,
        StartTime = DateTime.Now.AddDays(1),
        EndTime = DateTime.Now.AddDays(1).AddMinutes(15),
        IsAllDayEvent = false,
        Location = "Meeting room 10F",
        Reminder = Reminder.FifteenMinutes,
        Subject = "Project X planning meeting",
        Details = "Meeting to discuss Project X"
    };

task.Show();

SaveAppointmentTask has no Completed event; therefore, the only way to determine if the user completed the task, and did not cancel out of the task, is to query the appointment’s collection after the task has been shown. Yet, because the user has the option to change any or all of the information in the appointment before it is added to the calendar, there is no way of knowing for certain if the appointment has been saved.


Note

All properties of the SaveAppointmentTask are optional. If, however, you attempt to show the task and the EndTime occurs before the StartTime property, an InvalidOperationException is raised.


The source code for this section resides in the ContactsAndAppointments directory of the WPUnleashed.Examples project, in the downloadable sample code. The AppointmentCreationViewModel class contains various properties that map to properties of the SaveAppointmentTask class. An appbar button in the view allows the user to launch the task, which then launches the built-in Calendar app.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.162.249