ContactAnnotationStore.CreateAnnotationListAsync 方法

定义

重载

CreateAnnotationListAsync()

异步创建 ContactAnnotationList

CreateAnnotationListAsync(String)

异步创建 ContactAnnotationList 并将其与指定的用户数据帐户 ID 相关联。

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 并将其与指定的用户数据帐户 ID 相关联。

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 关联的用户数据帐户的 ID。 用户数据帐户必须归此应用所有。

返回

新创建的 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 中指定的用户数据帐户必须拥有此应用。

另请参阅

适用于