如何使用Windows Phone 8.1运行时应用程序中的ContactPicker和Contact类选择phonenumer?

时间:2015-02-12 11:46:51

标签: windows-phone-8.1

我也可以收到电子邮件和显示名称,但我找不到任何属性来获取我所选择的电话号码,我的代码在下面

var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker();             contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber);
            联系contact = await contactPicker.PickContactAsync();

        if (contact != null)
        {

        }

1 个答案:

答案 0 :(得分:0)

 string phoneNumber = string.Empty;
            var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker();
            contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber);
            Contact contact = await contactPicker.PickContactAsync();

            if (contact != null)
            {
                foreach (ContactPhone phone in contact.Phones as IList<ContactPhone>)
                {
                    phoneNumber = phone.Number;
                }
            }