共用方式為


ContactAnnotationStore.CreateAnnotationListAsync 方法

定義

多載

CreateAnnotationListAsync()

以非同步方式建立 ContactAnnotationList

CreateAnnotationListAsync(String)

以非同步方式建立 ContactAnnotationList ,並將它與指定的使用者帳戶識別碼產生關聯。

CreateAnnotationListAsync()

以非同步方式建立 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)

傳回

新建立的 ContactAnnotationList

屬性

Windows 需求

應用程式功能
contactsSystem

範例

下列範例提供可重複使用的方法,可用來建立批註清單、刪除特定批註清單,以及刪除存放區中的所有批註清單。

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;
}

另請參閱

適用於

CreateAnnotationListAsync(String)

以非同步方式建立 ContactAnnotationList ,並將它與指定的使用者帳戶識別碼產生關聯。

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)

參數

userDataAccountId
String

Platform::String

winrt::hstring

要與新 ContactAnnotationList建立關聯之使用者帳戶的識別碼。 此應用程式必須擁有使用者帳戶。

傳回

新建立的 ContactAnnotationList

屬性

Windows 需求

應用程式功能
contactsSystem

範例

下列範例提供可重複使用的方法,可用來建立批註清單、刪除特定批註清單,以及刪除存放區中的所有批註清單。

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;
}

備註

userDataAccountId中指定的使用者帳戶必須擁有此應用程式。

另請參閱

適用於