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

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...