1

我有这个代码:

private async void ButtonSelectContact_OnTapped(object sender, TappedRoutedEventArgs e)
{
    var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker
    {
        CommitButtonText = "Invite"
    };
    var contact = await contactPicker.PickSingleContactAsync();
    if (contact != null)
    {
        textBoxPerson.Text = contact.Name;
        textBoxEmail.Text = contact.Emails[0].ToString();
    }
}

..效果很好,除了选择联系人后,textBoxEmail.Text 包含“Windows.ApplicationModel.Contacts.ContactField”(应该类似于“rupertTpupkin@kingOfComedy.com”)。

4

2 回答 2

2

That's because contacts.Emails is a list of ContactField objects. Use contact.Emails[0].Value to get the email address you want. You can use .Type to retrieve the type of the email address.

Official MSDN documentation: http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.contacts.contactfield

于 2012-12-20T01:56:52.300 回答
1

因为他们在实现类的时候并没有重写ToString()方法,所以是调用Object的ToString()方法,返回类名。你可以打电话contact.Emails[0].Value来获取价值。

于 2012-12-20T01:56:02.683 回答