How do I get a contact list by code on Windows Phone 8.1?

Asked

Viewed 186 times

1

How to grab a Windows Phone’s contact list from an app and display it on a ListBox?

1 answer

2

Use the class ContactStore (that you get via the ContactManager). With the class you can use the method FindContactsAsync to get contacts, and with them assign the desired property in the property ItemsSource of ListBox.

Windows.ApplicationModel.Contacts.ContactStore contactStore;
contactStore = await Windows.ApplicationModel.Contacts.ContactManager.RequestStoreAsync();
var contacts = await contactStore.FindContactsAsync();
this.lstContacts.ItemsSource = contacts.Select(c => c.FirstName);

Remember that you need to enable the Capability "Contacts" in the app manifest.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.