我如何选择所有联系方式 [英] How Could I Pick All Contact Details
本文介绍了我如何选择所有联系方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Windows Mobile新手。开发Windows手机通用商店应用程序。
当我的应用程序启动时,我应该选择手机中提供的联系人姓名和电话号码。
任何人都可以指导我完成正确的教程。
我做了以下操作,获得了ListView中的所有联系人姓名。
I'm new to Windows Mobile. Developing a Windows phone Universal store application.
When my app starts i'm supposed to pick the Contact name and Phone Number available in the Phone.
Could any one guide me through a correct tutorial.
I did the following got all contact Names in ListView.
var contactStore = await ContactManager.RequestStoreAsync();
var contacts = await contactStore.FindContactsAsync();
foreach (var Item in contacts)
{
lstContact.Items.Add(Item.DisplayName);
}
但我如何得到以下格式的结果
姓名1
电话号码
姓名2
电话号码
:
:
名称n
电话号码
请求帮助。
But how do i get the result in following format
Name 1
Phone Number
Name 2
Phone Number
:
:
Name n
Phone Number
Request for help.
推荐答案
As就像我在MSDN上看到的那样,contactStore.FindContactsAsync()会返回一个联系人
[ ^ ]。
在foreach循环中,您可以使用Item.phones
[ ^ ]返回ContactPhones
[ ^ ]并且您可以使用名称Item.Name
[< a href =https://msdn.microsoft.com/en-us/library/windows.applicationmodel.contacts.contactphone.aspx\"target =_ blanktitle =New Window> ^ ]返回一个字符串。
无论如何,查看此页面以获取更多信息非常重要: https://msdn.microsoft.com/en-us/library/windo ws.applicationmodel.contacts.contact.aspx [ ^ ]
您的结果显示在列表框中,因为隐藏了对方法<$ c的调用$ c> ToString 当一个对象被添加到Listbox时如果缺少一个好的DataTemplate,那么你得到String
表示ContactPhone
对象。
我希望这会有所帮助。
LG
Hi,
As far as I've seen on MSDN, contactStore.FindContactsAsync() returns you a list ofcontacts
[^].
In the foreach loop you can retrieve the phone numbers by usingItem.phones
[^] which returns a list ofContactPhones
[^] and for the name you can useItem.Name
[^] which returns a string.
Anyway, it's very important for you to look at this page to get further information: https://msdn.microsoft.com/en-us/library/windows.applicationmodel.contacts.contact.aspx[^]
Your results are displayed like that in the listbox because there is a hidden call to the methodToString
when an object is added to the Listbox if a good DataTemplate is missing, so you get theString
representation of aContactPhone
object.
I hope this helps.
LG
这篇关于我如何选择所有联系方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文