Windows Phone 提供了获取联系人列表信息的API 学习

 Xaml文件
             <ListBox x:Name="ContactList" Margin="0,70,0,0">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=DisplayName, Mode=OneWay}" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
添加引用联系信息获取的相关API Microsoft.Phone.UserData
     1.首先创建Contacts对象,然后处理个查询完成事件(SearchCompleted)
    Contacts contacts = new Contacts();
        contacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(contacts_SearchCompleted);
  2.接下来就是调用查询,开始查找联系人
    contacts.SearchAsync(searchterm, FilterKind.PhoneNumber, null);
 该方法 在用户的联系人数据中异步搜索联系人信息,filter为筛选器 ,FilterKind筛选器种类,
   3.查询完成后会调用查询完成事件(SearchCompleted)
    
private void SearchCompleted(object sender, ContactsSearchEventArgs e)
    {
      
       ContactList.ItemsSource = e.Results; 
      }
 
 

你可能感兴趣的:(windows phone)