Address Chooser Task in Windows Phone

Windows Phone SDK provides the chooser “AddressChooserTask” that enables the users to retreive the physical address of the selected contact .

To use the Address Chooser Task in Windows Phone , follow the below steps

1. Add the namespace Microsoft.Phone.Tasks

2. Create an instance of the AddressChooserTask . Make sure that you declare the AddressChooserTask in the page scope and then add the event handler to the Completed property of the AddressChooserTask .

AddressChooserTask addressSelect;
addressSelect = new AddressChooserTask();
addressSelect.Completed += new EventHandler(addressSelect_Completed);

3. Call the Show method of the AddressChooserTask

addressSelect.Show();

4. This will launch the Contacts application where the user can select a contact , then the event “Completed” is raised which receives the address .

public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
AddressChooserTask addressSelect;
private void button1_Click(object sender, RoutedEventArgs e)
{
addressSelect = new AddressChooserTask();
addressSelect.Completed += new EventHandler(addressSelect_Completed);
addressSelect.Show();
}
void addressSelect_Completed(object sender, AddressResult e)
{
if (e.TaskResult == TaskResult.OK)
{
textBox1.Text = e.Address;
}
}
}

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...