如何在Windows Phone 8.1通用应用程序中的联系人中创建新联系人

时间:2014-10-23 12:13:41

标签: winrt-xaml windows-phone-8.1 win-universal-app

有没有办法在Windows Phone 8.1通用应用程序中创建新联系人?目前联系商店仅支持通过ID查找联系人或从联系人商店获取所有联系人?

1 个答案:

答案 0 :(得分:0)

啊!经过一番搜索后找到了解决方案应用可以创建自己的联系人商店,该商店出现在Windows Phone人员应用中。您只需要以下代码即可添加联系人....

using Windows.Phone.PersonalInformation;

 public async void CreateContact()
    {

        var contactStore = await ContactStore.CreateOrOpenAsync(ContactStoreSystemAccessMode.ReadWrite,ContactStoreApplicationAccessMode.LimitedReadOnly);
        var createContactQuery = contactStore.CreateContactQuery();

        ContactInformation ci = new ContactInformation();
        ci.DisplayName ="Muhammad saifullah";

      ///Save Thumbnail image.
       HttpClient client = new HttpClient();
        var data = await client.GetInputStreamAsync(new Uri("imageurlhere"));
        await ci.SetDisplayPictureAsync(data);

        StoredContact sc = new StoredContact(contactStore, ci);
        IDictionary<string, object> props = await sc.GetPropertiesAsync();
        props.Add(KnownContactProperties.Email, "myemail@domcin.com");
        props.Add(KnownContactProperties.MobileTelephone, "+1000000101001");
        props.Add(KnownContactProperties.JobTitle, "---");


        await sc.SaveAsync();           

    }