How to use SaveContactTask to save contact in Windows Phone ?

The Windows Phone SDK provides the SaveContactTask that enables the users to save a contact from your windows phone App .

To use the SaveContactTask , follow the below steps

1. Add the namespace “using Microsoft.Phone.Tasks;”

2. Declare Initialize the SaveContactTask along with the event handler for the Completed Event for SaveContactTask .

SaveContactTask SaveContact;
public MainPage()
{
InitializeComponent();
SaveContact = new SaveContactTask();
SaveContact.Completed += new EventHandler(SaveContact_Completed);
}
void SaveContact_Completed(object sender, SaveContactResult e)
{
if (e.TaskResult == TaskResult.OK)
{
MessageBox.Show("Saved");
}
}

3. Fill the necessary properties(optional) of the SaveContactTask that needs to be saved and call the show method of the SaveContact

SaveContact.FirstName = "senthil";
SaveContact.Website = "www.developerpublish.com";
SaveContact.Show();

4. This will show the Screen which enables the user to modify / update the properties . The user should click the save icon to save the contact .

No Responses

Leave a Reply