How to get contact list by code in Windows Phone 8.1?

1

How do I get the contact list of a Windows Phone by an application and display it in a ListBox ?

    
asked by anonymous 18.10.2014 / 22:48

1 answer

2

Use the class ContactStore ( that you get via the ContactManager ). With the class you can use the method FindContactsAsync to get the contacts, and with them assign the desired property in the ItemsSource property 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 Capability of "Contacts" in the app's application manifest.

    
20.10.2014 / 05:59