Floating FB popout byF5debug

101 How to on Windows Phone – How to #78 – How to use the Save Appointment Task in Windows Phone Application

 

In this article we are going to see how to use the Save Appointment Launcher Task in Windows Phone application development. This task is available on in Windows Phone 8 and not in the previous versions. The SaveAppointment Launcher task is used to save an appointment for the end user in simple steps, with launching the Calendar application and showing the available appointments. The task has a list of properties which can be used to assign the appropriate values to save the appointment locally. This launcher task is released recently in Windows Phone 8 and this task can be directly used from the application to save any kind of appointments. Let us see the steps on how to achieve this task in our Windows Phone application development. Open Visual Studio 2012 IDE and create a new Windows Phone project with a valid project name as shown in the screen below.   [more]

image

Clicking on OK will create the project and the solution with the list of default files and folders that are required to run the application. It will take some time to create these files based on your system configuration, so once everything is ready we can see the Visual Studio IDE with the project as shown in the screen below.

image


Let us add some control to trigger the SaveAppointment launcher task instance and assign the appropriate value to be saved. We will add a button control alone and add some static value to be saved as an appointment as shown in the code below.

XAML Code:

[code:c#]

<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="F5debug How to Series" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="SaveAppointment" 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">
            <Button Content="Save an Appointment" HorizontalAlignment="Left" Margin="30,10,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.434,0.523" Width="416" Click="Button_Click" Height="138"/>
        </Grid>

[/code]

image


In the code behind, button click event we need to create an instance of the SaveAppointment class and assign the values to the different properties which are self explanatory as shown in the code below.

C# Code:

[code:c#]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using F5debugHowto78.Resources;
using Microsoft.Phone.Tasks;

namespace F5debugHowto78
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SaveAppointmentTask SATask = new SaveAppointmentTask();

            SATask.StartTime = DateTime.Now.AddHours(5);
            SATask.EndTime = DateTime.Now.AddHours(2);

            SATask.Subject = "F5debug App Subject";
            SATask.Location = "F5debug Office";
            SATask.Details = "This is a sample Appointment";
           
            SATask.Reminder = Reminder.TenMinutes;

            SATask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;

            SATask.Show();
        }      
    }
}

[/code]

Now we are done with the code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected output.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter