Skip to main content
ContactPickerUI.ContainsContact | containsContact method

Checks to see whether the contact was already selected by the user.

Note  The Contact.Id property must be set when you call ContainsContact. If Contact.Id isn't set, your app won't be able to find the contact.
 

Syntax


var boolean = contactPickerUI.containsContact(id);

public bool ContainsContact(
  string id
)

Public Function ContainsContact(
  id As String 
) As Boolean

public:
bool ContainsContact(
  String^ id
)

Parameters

id

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The ID of the contact.

Return value

Type: Boolean [JavaScript] | System.Boolean [.NET] | Platform::Boolean [C++]

True if the contact has already been selected; otherwise, false.

Examples

The following example checks whether a particular contact is selected and, if so, removes it.


function removeContactFromBasket(sampleContact) {
    // Programmatically remove the contact from the basket.
    if (contactPickerUI.containsContact(sampleContact.id)) {
        contactPickerUI.removeContact(sampleContact.id);
        document.getElementById("statusMessage").innerText = sampleContact.name + " was removed from the basket";
    }
}

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.ApplicationModel.Contacts.Provider
Windows::ApplicationModel::Contacts::Provider [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

Windows.ApplicationModel.Contacts.Provider
Windows::ApplicationModel::Contacts::Provider [C++]

Metadata

Windows.winmd

See also

Contact Picker app sample
ContactPickerUI