Contact, classe
Réduire la table des matières
Développer la table des matières

Contact Class

Représente un contact.

Syntaxe


var contact = new Windows.ApplicationModel.Contacts.Contact();

Attributs

[MarshalingBehavior(Agile)]
[Version(0x06020000)]

Membres

ContactClasse possède ces types de membres :

Constructeurs

ContactClasse possède ces constructeurs.

ConstructeurDescription
Contact Creates a new instance of the Contact class.

 

Méthodes

The Contact Classe hérite des méthodes de Object Classe (C#/VB/C++).

Propriétés

Le ContactClasse a les propriétés suivantes.

PropriétéType d'accèsDescription

Addresses

En lecture seuleGets the contact addresses for a contact.

ConnectedServiceAccounts

En lecture seuleGets the connected service accounts for a contact.

DataSuppliers

En lecture seuleGets the data suppliers for a contact. The maximum string length for each data supplier is 50 characters.

DisplayName

En lecture seuleGets the display name for a contact. You can only access this property from a UI thread.

Emails

En lecture seuleGets the email addresses for a contact.

Fields

En lecture seuleFields may be altered or unavailable for releases after Windows 8.1. Instead, use Phones, Emails, Addresses, or ConnectedServiceAccounts. Sets the fields that contain information about a contact.

FirstName

Lecture/écritureGets and sets the first name for a contact. The maximum string length for the first name is 64 characters.

HonorificNamePrefix

Lecture/écritureGets and sets the honorific prefix for the name for a contact. The maximum string length for the honorific prefix is 32 characters.

HonorificNameSuffix

Lecture/écritureGets and sets the honorific suffix for the name for a contact. The maximum string length for the honorific suffix is 32 characters.

Id

Lecture/écritureGets and sets the identifier for a contact. The maximum string length for the identifier is 256 characters.

ImportantDates

En lecture seuleGets the important dates for a contact.

JobInfo

En lecture seuleGets the job info items for a contact.

LastName

Lecture/écritureGets and sets the last name for a contact. The maximum string length for the last name is 64 characters.

MiddleName

Lecture/écritureGets and sets the middle name for a contact. The maximum string length for the middle name is 64 characters.

Name

Lecture/écritureName may be altered or unavailable for releases after Windows 8.1. Instead, use FirstName. Sets and gets the name of the contact.

Notes

Lecture/écritureGets and sets notes for a contact. The maximum string length for notes is 4096 characters.

Phones

En lecture seuleGets info about the phones for a contact.

ProviderProperties

En lecture seuleGets the property set object for the contact.

SignificantOthers

En lecture seuleGets the significant others for a contact.

Thumbnail

Lecture/écritureGets or sets a thumbnail image that represents this contact.

Websites

En lecture seuleGets the Web sites for a contact.

YomiDisplayName

En lecture seuleGets the Yomi (phonetic Japanese equivalent) display name for a contact.

YomiFamilyName

Lecture/écritureGets the Yomi (phonetic Japanese equivalent) family name for a contact. The maximum string length for the Yomi family name is 120 characters.

YomiGivenName

Lecture/écritureGets the Yomi (phonetic Japanese equivalent) given name for a contact. The maximum string length for the Yomi given name is 120 characters.

 

Remarques

Quel que soit votre mode de stockage des informations de contact dans votre application, vous devez être en mesure de placer ces informations dans un objet Contact. Ainsi les autres applications qui permettent aux utilisateurs de sélectionner des contacts peuvent utiliser votre application et traiter les informations de contact qu'elle fournit.

Exemples

Ce code montre comment votre application peut prendre un objet contact spécifique à l'application et l'utiliser pour créer un objet Contact. D'abord, voici un exemple d'objet qui contient des informations de contact.


var sampleContacts = [
    {
        firstName: "Kim",
        lastName: "Abercrombie",
        image: "KimAbercrombie.jpg",
        personalEmail: "kim@contoso.com",
        homePhone: "921 555-0187",
        address: {
            full: "123 Main St, Redmond WA, 23456",
            street: "123 Main St",
            city: "Redmond",
            state: "WA",
            zipCode: "23456"
        },
        id: "49b0652e-8f39-48c5-853b-e5e94e6b8a11"
    }
];


Cette fonction génère le contact qui prend en charge plusieurs champs :


function createContactForBasket(sampleContact) {

    // Transfer contact data to a Contact object
    var contact = new Windows.ApplicationModel.Contacts.Contact();
    contact.firstName = sampleContact.firstName;
    contact.lastName = sampleContact.lastName;
    contact.id = sampleContact.id;

    // Add the personal email address to the Contact object’s emails vector
    var personalEmail = new Windows.ApplicationModel.Contacts.ContactEmail();
    personalEmail.address = sampleContact.personalEmail;
    personalEmail.kind = Windows.ApplicationModel.Contacts.ContactEmailKind.personal;
    contact.emails.append(personalEmail);

    // Adds the home phone number to the Contact object’s phones vector
    var homePhone = new Windows.ApplicationModel.Contacts.ContactPhone();
    homePhone.number = sampleContact.homePhone;
    homePhone.kind = Windows.ApplicationModel.Contacts.ContactPhoneKind.home;
    contact.phones.append(homePhone);

    // Adds the address to the Contact object’s addresses vector
    var homeAddress = new Windows.ApplicationModel.Contacts.ContactAddress();
    homeAddress.streetAddress = sampleContact.address.street;
    homeAddress.locality = sampleContact.address.city;
    homeAddress.region = sampleContact.address.state;
    homeAddress.postalCode = sampleContact.address.zipCode;
    homeAddress.kind = Windows.ApplicationModel.Contacts.ContactAddressKind.home;
    contact.addresses.append(homeAddress);

    // Sets the thumbnail for the contact from path
    Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(sampleContact.image).then(
          function (imageFile) {
                 var streamReference = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile);
                 contact.thumbnail = randomAccessStreamReference;
          });

    return contact;
}


Conditions requises

Client minimal pris en charge

Windows 8 [Applications Windows Store uniquement]

Serveur minimal pris en charge

Windows Server 2012 [Applications Windows Store uniquement]

Espace de noms

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

Métadonnées

Windows.winmd

 

 

Afficher:
© 2017 Microsoft