ContactPicker
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// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
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);
});
}
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 .
Constructors
ContactPicker() ContactPicker() ContactPicker() ContactPicker()
Creates a new instance of the ContactPicker class.
public : ContactPicker()public ContactPicker()Public Sub New()// You can use this method in JavaScript.
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 : PlatForm::String CommitButtonText { get; set; }public string CommitButtonText { get; set; }Public ReadWrite Property CommitButtonText As string// You can use this property in JavaScript.
- Value
- PlatForm::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 IList<string> DesiredFields { get; }Public ReadOnly Property DesiredFields As IList<string>// You can use this property in JavaScript.
- Value
- IVector<PlatForm::String> IList<string> IList<string> IList<string>
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 IList<ContactFieldType> DesiredFieldsWithContactFieldType { get; }Public ReadOnly Property DesiredFieldsWithContactFieldType As IList<ContactFieldType>// You can use this property in JavaScript.
- Value
- IVector<ContactFieldType> IList<ContactFieldType> IList<ContactFieldType> IList<ContactFieldType>
An array of ContactFieldType -typed values for a contact.
Remarks
For info about how to select contacts, see Selecting contacts and Quickstart: Selecting user contacts .
- See Also
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 ContactSelectionMode// You can use this property in JavaScript.
The mode for the Contact Picker user interface. You can set this to Contacts or Fields.
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
Gets the User associated with the ContactPicker.
public : User User { get; }public User User { get; }Public ReadOnly Property User As User// You can use this property in JavaScript.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
Methods
CreateForUser(User) 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// You can use this method in JavaScript.
Returns a ContactPicker for the account specified by the user parameter.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
IsSupportedAsync() IsSupportedAsync() IsSupportedAsync() IsSupportedAsync()
Gets a Boolean value indicating if the contact picker is supported on the current platform.
public : static IAsyncOperation<PlatForm::Boolean> IsSupportedAsync()public static IAsyncOperation<bool> IsSupportedAsync()Public Static Function IsSupportedAsync() As IAsyncOperation( Of bool )// You can use this method in JavaScript.
A Boolean value indicating if the contact picker is supported on the current platform.
| Device family |
Windows 10 Creators Update (introduced v10.0.15063.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v4)
|
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 )// You can use this method in JavaScript.
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 .
- See Also
PickContactsAsync() PickContactsAsync() PickContactsAsync() PickContactsAsync()
Launches the Contact Picker for selecting multiple contacts.
public : IAsyncOperation<IVector<Contact>> PickContactsAsync()public IAsyncOperation<IList<Contact>> PickContactsAsync()Public Function PickContactsAsync() As IAsyncOperation( Of IListContact )// You can use this method in JavaScript.
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 .
- See Also
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<IReadOnlyList<ContactInformation>> PickMultipleContactsAsync()Public Function PickMultipleContactsAsync() As IAsyncOperation( Of IReadOnlyListContactInformation )// You can use this method in JavaScript.
The operation that launches the contact picker.
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;
});
});
}
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.
- See Also
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 )// You can use this method in JavaScript.
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.
- See Also