Mohab
Mohab

Reputation: 109

How can I use SaveContactTask without exiting program in WP7?

When I use this task I can't do any thing in my application after saving the contact except showing a messagebox with a message how can I return again to my application when this task completed !!

Upvotes: 0

Views: 142

Answers (1)

Sergei Grebnov
Sergei Grebnov

Reputation: 2623

This should work out the box. When task is finished your application takes control again. You can control task result using Completed event handler

this.saveContactTask.Completed += new EventHandler<SaveContactResult>(saveContactTask_Completed);

private void saveContactTask_Completed(object sender, SaveContactResult e)
{
    switch (e.TaskResult)
    {
        case TaskResult.OK:
        MessageBox.Show("Contact is successfully saved.");
        break;
        case TaskResult.Cancel:
        MessageBox.Show("The user canceled the task.");
        break;
        case TaskResult.None:
        MessageBox.Show("NO information regarding the task result is available.");
        break;
    }
}

Here you can find fully functional example which works exactly as you want. You may take a look and compare with your implementation

http://windowsphonegeek.com/tips/8-How-to-use-SaveContactTask-in-Windows-Phone-Mango

Upvotes: 3

Related Questions