Bagikan melalui


ContactAnnotationStore.CreateAnnotationListAsync Metode

Definisi

Overload

CreateAnnotationListAsync()

Secara asinkron membuat ContactAnnotationList.

CreateAnnotationListAsync(String)

Secara asinkron membuat ContactAnnotationList dan mengaitkannya dengan ID akun data pengguna yang ditentukan.

CreateAnnotationListAsync()

Secara asinkron membuat ContactAnnotationList.

public:
 virtual IAsyncOperation<ContactAnnotationList ^> ^ CreateAnnotationListAsync() = CreateAnnotationListAsync;
/// [Windows.Foundation.Metadata.Overload("CreateAnnotationListAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<ContactAnnotationList> CreateAnnotationListAsync();
[Windows.Foundation.Metadata.Overload("CreateAnnotationListAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<ContactAnnotationList> CreateAnnotationListAsync();
function createAnnotationListAsync()
Public Function CreateAnnotationListAsync () As IAsyncOperation(Of ContactAnnotationList)

Mengembalikan

ContactAnnotationList yang baru dibuat.

Atribut

Persyaratan Windows

Kemampuan aplikasi
contactsSystem

Contoh

Contoh berikut menyediakan metode yang dapat digunakan kembali untuk membuat daftar anotasi, menghapus daftar anotasi tertentu, dan menghapus semua daftar anotasi di penyimpanan.

public async Task<ContactAnnotationList> CreateAnnotationList()
{
    // Get the data store.
    ContactAnnotationStore store = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

    // Create a new list.
    ContactAnnotationList list = await store.CreateAnnotationListAsync();

    // Find the list to verify it was created.
    IReadOnlyList<ContactAnnotationList> lists = await store.FindAnnotationListsAsync();

    for (int i = 0; i < lists.Count; i++)
    {
        // Do the IDs match?
        if (list.Id == lists[i].Id)
        {
            // Found it! Return the new list.
            return(list);
        }
    }

    // List not created, return null.
    return(null);
}

public async Task<Boolean> DeleteAnnotationList(string listId)
{
    // Get the store.
    ContactAnnotationStore store = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

    // Find the list.
    ContactAnnotationList list = await store.GetAnnotationListAsync(listId);

    // Make sure we got it.
    if (list.Id == listId)
    {
        // Delete the list.
        await list.DeleteAsync();
        return true;
    }

    return false;
}

public async Task<Boolean> DeleteAllAnnotationLists()
{
    // Get the store.
    ContactAnnotationStore store = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

    IReadOnlyList<ContactAnnotationList> lists = await store.FindAnnotationListsAsync();

    // Make sure at least one annotation list exists.
    if (lists.Count > 0)
    {
        // Find the list.
        for (int i = 0; i < lists.Count; i++)
        {
            await lists[i].DeleteAsync();
        }

        return true;
    }

    return false;
}

Lihat juga

Berlaku untuk

CreateAnnotationListAsync(String)

Secara asinkron membuat ContactAnnotationList dan mengaitkannya dengan ID akun data pengguna yang ditentukan.

public:
 virtual IAsyncOperation<ContactAnnotationList ^> ^ CreateAnnotationListAsync(Platform::String ^ userDataAccountId) = CreateAnnotationListAsync;
/// [Windows.Foundation.Metadata.Overload("CreateAnnotationListInAccountAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<ContactAnnotationList> CreateAnnotationListAsync(winrt::hstring const& userDataAccountId);
[Windows.Foundation.Metadata.Overload("CreateAnnotationListInAccountAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<ContactAnnotationList> CreateAnnotationListAsync(string userDataAccountId);
function createAnnotationListAsync(userDataAccountId)
Public Function CreateAnnotationListAsync (userDataAccountId As String) As IAsyncOperation(Of ContactAnnotationList)

Parameter

userDataAccountId
String

Platform::String

winrt::hstring

ID untuk akun data pengguna untuk mengaitkan ContactAnnotationList baru. Akun data pengguna harus dimiliki oleh aplikasi ini.

Mengembalikan

ContactAnnotationList yang baru dibuat.

Atribut

Persyaratan Windows

Kemampuan aplikasi
contactsSystem

Contoh

Contoh berikut menyediakan metode yang dapat digunakan kembali untuk membuat daftar anotasi, menghapus daftar anotasi tertentu, dan menghapus semua daftar anotasi di penyimpanan.

public async Task<ContactAnnotationList> CreateAnnotationList()
{
    // Get the data store.
    ContactAnnotationStore store = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

    // Create a new list.
    ContactAnnotationList list = await store.CreateAnnotationListAsync();

    // Find the list to verify it was created.
    IReadOnlyList<ContactAnnotationList> lists = await store.FindAnnotationListsAsync();

    for (int i = 0; i < lists.Count; i++)
    {
        // Do the IDs match?
        if (list.Id == lists[i].Id)
        {
            // Found it! Return the new list.
            return(list);
        }
    }

    // List not created, return null.
    return(null);
}

public async Task<Boolean> DeleteAnnotationList(string listId)
{
    // Get the store.
    ContactAnnotationStore store = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

    // Find the list.
    ContactAnnotationList list = await store.GetAnnotationListAsync(listId);

    // Make sure we got it.
    if (list.Id == listId)
    {
        // Delete the list.
        await list.DeleteAsync();
        return true;
    }

    return false;
}

public async Task<Boolean> DeleteAllAnnotationLists()
{
    // Get the store.
    ContactAnnotationStore store = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite);

    IReadOnlyList<ContactAnnotationList> lists = await store.FindAnnotationListsAsync();

    // Make sure at least one annotation list exists.
    if (lists.Count > 0)
    {
        // Find the list.
        for (int i = 0; i < lists.Count; i++)
        {
            await lists[i].DeleteAsync();
        }

        return true;
    }

    return false;
}

Keterangan

Akun data pengguna yang ditentukan dalam userDataAccountId harus dimiliki aplikasi ini.

Lihat juga

Berlaku untuk