ContactPickerUI Class

Ermöglicht es Ihnen, die Kontaktauswahlbenutzeroberfläche aufzurufen, sodass Sie eine oder mehrere Kontakte auswählen können.

Syntax


/* Weitere Informationen zum Erstellen oder Zugreifen auf dieses Objekt finden Sie unter "Hinweise". */

Attribute

[Version(0x06020000)]

Member

ContactPickerUIKlasse hat diese Membertypen:

Ereignisse

ContactPickerUIKlasse hat diese Ereignisse.

EreignisBeschreibung
ContactRemoved Occurs when the user deselects or removes the contact.

 

Methoden

The ContactPickerUI Klasse hat diese Methoden. Mit C#, Visual Basic und C++ erbt es auch Methoden aus Object Klasse.

MethodeBeschreibung
AddContact(Contact) Adds a Contact. The Contact.Id property must be set when you call AddContact. If Contact.Id isn't set, your app will fail.
AddContact(String, Contact) AddContact may be altered or unavailable for releases after Windows 8.1. Instead, use AddContact without the ID. Adds a Contact.
ContainsContact Checks to see whether the contact was already selected by the user.
RemoveContact Removes a contact.

 

Eigenschaften

Der ContactPickerUIKlasse hat diese Eigenschaften.

EigenschaftZugriffstypBeschreibung

DesiredFields

SchreibgeschütztDesiredFields may be altered or unavailable for releases after Windows 8.1. Instead, use DesiredFieldsWithContactFieldType. Specifies the fields that you want returned after the user selects one or more contacts.

DesiredFieldsWithContactFieldType

SchreibgeschütztGets the fields with contact field type that you want returned after the user selects one or more contacts.

SelectionMode

SchreibgeschütztDetermines the selection mode for the contact picker. The most common options are PickSingleContactAsync or PickMultipleContactsAsync.

 

Hinweise

Ein Beispiel zum Verwenden dieser Klasse finden Sie unter Codebeispiel.

Beispiele

Dieser Beispielcode bereitet die Seite vor, um ContactPickerUI zu verwenden:



var contactPickerUI;

    var page = WinJS.UI.Pages.define("/html/contactPickerScenario.html", {
        processed: function (element, uri) {
            // During an initial activation this event is called before the system splash screen is torn down.
            sampleContacts.forEach(createContactUI);
        },

        ready: function (element, options) {
            // During an initial activation this event is called after the system splash screen is torn down.
            // Do any initialization work that is not related to getting the initial UI setup.
            contactPickerUI = options.contactPickerUI;
            contactPickerUI.addEventListener("contactremoved", onContactRemoved, false);
        },

        unload: function () {
            contactPickerUI.removeEventListener("contactremoved", onContactRemoved, false);
        }
});


Dieser Beispielcode zeigt, wie mithilfe der AddContact(Contact)-Methode ein Kontakt zum Korb hinzugefügt wird.



var contact = createContactForBasket(sampleContacts[0])

// Add the contact to the basket
var statusMessage = document.getElementById("statusMessage");
     switch (contactPickerUI.addContact(contact)) {
     case Windows.ApplicationModel.Contacts.Provider.AddContactResult.added:
         // Notify user that the contact was added to the basket
         statusMessage.innerText = contact.displayName + " was added to the basket";
         break;
     case Windows.ApplicationModel.Contacts.Provider.AddContactResult.alreadyAdded:
         // Notify the user that the contact is already in the basket
         statusMessage.innerText = contact.displayName + " is already in the basket";
         break;
     case Windows.ApplicationModel.Contacts.Provider.AddContactResult.unavailable:
     default:
         // Notify the user that the basket is not currently available
         statusMessage.innerText = contact.displayName + " could not be added to the basket";
         break;
}


Dieser Beispielcode zeigt, wie ein Kontakt aus dem Korb entfernt und auf das Entfernen reagiert wird.


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


Anforderungen

Mindestens unterstützter Client

Windows 8 [Nur Windows Store-Apps]

Mindestens unterstützter Server

Windows Server 2012 [Nur Windows Store-Apps]

Namespace

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

Metadaten

Windows.winmd

 

 

Anzeigen:
© 2014 Microsoft