ContactPicker ContactPicker ContactPicker ContactPicker Class

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

Syntax

Declaration

public sealed class ContactPickerpublic sealed class ContactPickerPublic NotInheritable Class ContactPickerpublic sealed class ContactPicker

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 summary

Creates a new instance of the ContactPicker class.

Properties summary

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

Note

This property is no longer available starting with Windows 10.

Sets the contact fields your app is interested in.

Note

This property is no longer available starting with Windows 10.

Gets the ways to connect with a contact.

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.

Prerelease. Gets the User associated with the ContactPicker.

Methods summary

Prerelease. Creates a new ContactPicker for a specific User.

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

Launches the Contact Picker to select a single contact.

Launches the Contact Picker for selecting multiple contacts.

Launches the Contact Picker for selecting multiple contacts.

Note

This method is no longer available starting with Windows 10.

Launches the Contact Picker for selecting a single contact.

Note

This method is no longer available starting with Windows 10.

Constructors

  • ContactPicker()
    ContactPicker()
    ContactPicker()
    ContactPicker()

    Creates a new instance of the ContactPicker class.

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

    Remarks

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

Properties

  • CommitButtonText
    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 stringpublic string CommitButtonText { get; set; }

    Property Value

    • string
      string
      string
      string

      The text of the button.

    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
    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>public IVector<string> DesiredFields { get; }

    Property Value

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

    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
    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>public IVector<ContactFieldType> DesiredFieldsWithContactFieldType { get; }

    Property Value

    Remarks

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

  • SelectionMode
    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 ContactSelectionModepublic ContactSelectionMode SelectionMode { get; set; }

    Property Value

    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
    User

    Prerelease. Gets the User associated with the ContactPicker.

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

    Property Value

Methods

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

    Prerelease. 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 ContactPickerpublic static ContactPicker CreateForUser(User user)

    Parameters

    Returns

  • IsSupportedAsync()
    IsSupportedAsync()
    IsSupportedAsync()
    IsSupportedAsync()

    Prerelease. 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 )public static IAsyncOperation<bool> IsSupportedAsync()

    Returns

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

  • PickContactAsync()
    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 )public IAsyncOperation<Contact> PickContactAsync()

    Returns

    • The operation that launches the Contact Picker.

    Remarks

    To pick multiple contacts at once, use PickContactsAsync().

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

  • PickContactsAsync()
    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 )public IAsyncOperation<IVector<Contact>> PickContactsAsync()

    Returns

    • The operation that launches the contact picker.

    Remarks

    To pick only a single contact, use PickContactAsync().

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

  • PickMultipleContactsAsync()
    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 )public IAsyncOperation<IVectorView<ContactInformation>> PickMultipleContactsAsync()

    Returns

    • The operation that launches the contact picker.

    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()
    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 )public IAsyncOperation<ContactInformation> PickSingleContactAsync()

    Returns

    • The operation that launches the Contact Picker.

    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.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.ApplicationModel.Contacts.dll