ContactPicker ContactPicker ContactPicker Class

Definition

Controls how the Contact Picker user interface opens and what information it shows.

public sealed class ContactPicker : IContactPicker, IContactPicker2, IContactPicker3public sealed class ContactPicker : IContactPicker, IContactPicker2, IContactPicker3Public NotInheritable Class ContactPicker Implements IContactPicker, IContactPicker2, IContactPicker3
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The ContactPicker class enables users to select one or more contacts from any app that supports the Contact Picker contract. You can configure the ContactPicker class to accept only a single contact, or multiple contacts. In addition, you can request that the app providing the contact information return the entire set of data for each contact, or just specific fields.

Note

Apps that were compiled for Windows 8 but running on Windows 8.1 may encounter runtime errors without compile-time errors.

For info about how to select contacts, see Selecting contacts and Quickstart: Selecting user contacts .

Examples

This example demonstrates using the ContactPicker to get the name and email address of a single contact.


function selectContact() {
    // Create the picker
    var picker = new Windows.ApplicationModel.Contacts.ContactPicker();
    picker.commitButtonText = "Select";
    picker.selectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.fields;
    picker.desiredFieldsWithContactFieldType.append(Windows.ApplicationModel.Contacts.ContactFieldType.email);    

    // Open the picker for the user to select a contact
    picker.pickContactAsync().done(function (contact) {
        var contactElement = document.createElement("div");
        contactElement.innerText = contact.name + " " + contact.emails[0].address;
        document.body.appendChild(contactElement);
    });
}

Constructors

ContactPicker() ContactPicker() ContactPicker()

Creates a new instance of the ContactPicker class.

public ContactPicker()public ContactPicker()Public Sub New()
Attributes

Remarks

To select contacts, create an instance of this class and then use either the PickSingleContactAsync or PickMultipleContactsAsync method.

Properties

CommitButtonText CommitButtonText CommitButtonText

Sets the text for the confirmation button in the Contact Picker user interface.

Note

This property is no longer available starting with Windows 10.

public string CommitButtonText { get; set; }public string CommitButtonText { get; set; }Public ReadWrite Property CommitButtonText As string
Value
string string string

The text of the button.

Attributes

Remarks

We recommend you set CommitButtonText to provide an indication to the user that they have selected a contact or set of contacts.

DesiredFields DesiredFields DesiredFields

Sets the contact fields your app is interested in.

Note

This property is no longer available starting with Windows 10.

public IVector<string> DesiredFields { get; }public IVector<string> DesiredFields { get; }Public ReadOnly Property DesiredFields As IVector<string>
Value

An array of strings that represent the field names your app is interested in.

Attributes

Remarks

If you choose only one field with this method, a contact is considered a match if it has that field. If you choose multiple fields, a contact is considered a match if it has any of the fields.

When selecting fields, list them in order of preference. For example, if you want both phone numbers and email addresses, but prefer phone numbers, put the PhoneNumber field before the Email field.

To specify a specific field, use the KnownContactField class.

DesiredFieldsWithContactFieldType DesiredFieldsWithContactFieldType DesiredFieldsWithContactFieldType

Gets the ways to connect with a contact.

public IVector<ContactFieldType> DesiredFieldsWithContactFieldType { get; }public IVector<ContactFieldType> DesiredFieldsWithContactFieldType { get; }Public ReadOnly Property DesiredFieldsWithContactFieldType As IVector<ContactFieldType>
Value

An array of ContactFieldType -typed values for a contact.

Attributes

Remarks

For info about how to select contacts, see Selecting contacts and Quickstart: Selecting user contacts .

See Also

SelectionMode SelectionMode SelectionMode

Controls whether the Contact Picker shows contacts as a complete entity or as a collection of fields.

Note

This property is no longer available starting with Windows 10.

public ContactSelectionMode SelectionMode { get; set; }public ContactSelectionMode SelectionMode { get; set; }Public ReadWrite Property SelectionMode As ContactSelectionMode
Value
ContactSelectionMode ContactSelectionMode ContactSelectionMode

The mode for the Contact Picker user interface. You can set this to Contacts or Fields.

Attributes

Remarks

A contact can contain a lot of information. If you want all of this information, set the SelectionMode property to return the entire contact. If you are only interested in specific fields, set this property to return only a selection of fields, then use the DesiredFields property to specify which fields you want.

Use the ContactSelectionMode enumeration to set the value of this property.

User User User

Gets the User associated with the ContactPicker.

public User User { get; }public User User { get; }Public ReadOnly Property User As User
Value
User User User

The User associated with the ContactPicker.

Attributes

Methods

CreateForUser(User) CreateForUser(User) CreateForUser(User)

Creates a new ContactPicker for a specific User.

public static ContactPicker CreateForUser(User user)public static ContactPicker CreateForUser(User user)Public Static Function CreateForUser(user As User) As ContactPicker
Parameters
user
User User User

The User for which you want to create the ContactPicker.

Returns

Returns a ContactPicker for the account specified by the user parameter.

Attributes

IsSupportedAsync() IsSupportedAsync() IsSupportedAsync()

Gets a Boolean value indicating if the contact picker is supported on the current platform.

public static IAsyncOperation<bool> IsSupportedAsync()public static IAsyncOperation<bool> IsSupportedAsync()Public Static Function IsSupportedAsync() As IAsyncOperation( Of bool )
Returns

A Boolean value indicating if the contact picker is supported on the current platform.

Attributes

PickContactAsync() PickContactAsync() PickContactAsync()

Launches the Contact Picker to select a single contact.

public IAsyncOperation<Contact> PickContactAsync()public IAsyncOperation<Contact> PickContactAsync()Public Function PickContactAsync() As IAsyncOperation( Of Contact )
Returns

The operation that launches the Contact Picker.

Attributes

Remarks

To pick multiple contacts at once, use PickContactsAsync.

For info about how to select contacts, see Selecting contacts and Quickstart: Selecting user contacts .

See Also

PickContactsAsync() PickContactsAsync() PickContactsAsync()

Launches the Contact Picker for selecting multiple contacts.

public IAsyncOperation<IVector<Contact>> PickContactsAsync()public IAsyncOperation<IVector<Contact>> PickContactsAsync()Public Function PickContactsAsync() As IAsyncOperation( Of IVectorContact )
Returns

The operation that launches the contact picker.

Attributes

Remarks

To pick only a single contact, use PickContactAsync.

For info about how to select contacts, see Selecting contacts and Quickstart: Selecting user contacts .

See Also

PickMultipleContactsAsync() PickMultipleContactsAsync() PickMultipleContactsAsync()

Launches the Contact Picker for selecting multiple contacts.

Note

This method is no longer available starting with Windows 10.

public IAsyncOperation<IVectorView<ContactInformation>> PickMultipleContactsAsync()public IAsyncOperation<IVectorView<ContactInformation>> PickMultipleContactsAsync()Public Function PickMultipleContactsAsync() As IAsyncOperation( Of IVectorViewContactInformation )
Returns

The operation that launches the contact picker.

Attributes

Remarks

To pick only a single contact, use PickSingleContactAsync.

Use the SelectionMode property to control whether your app receives all of a contact's information, or just specific fields.

Examples

This example demonstrates how to use PickMultipleContactsAsync to get multiple contacts.

function selectContacts() {
    var picker = Windows.ApplicationModel.Contacts.ContactPicker();
    picker.commitButtonText = "Select";
    picker.pickMultipleContactsAsync().then(function (contacts) {
        contacts.forEach(function (contact) {
            var contactElement = document.createElement("div");
            contactElement.innerText = contact.name;
        });
    });
}

PickSingleContactAsync() PickSingleContactAsync() PickSingleContactAsync()

Launches the Contact Picker for selecting a single contact.

Note

This method is no longer available starting with Windows 10.

public IAsyncOperation<ContactInformation> PickSingleContactAsync()public IAsyncOperation<ContactInformation> PickSingleContactAsync()Public Function PickSingleContactAsync() As IAsyncOperation( Of ContactInformation )
Returns

The operation that launches the Contact Picker.

Attributes

Remarks

To pick multiple contacts at once, use PickMultipleContactsAsync.

Use the SelectionMode property to control whether your app receives all of a contact's information, or just specific fields.

See Also