3
我想要获取我的联系人中以特定3位数字开头的所有电话号码,例如,当我点击按钮时显示“012”。通过电话号码搜索联系人,使用3位数字前缀进行过滤
,我一直在努力使用下面的代码:
private void ButtonContacts_Click(object sender, RoutedEventArgs e)
{
Contacts cons = new Contacts();
//Identify the method that runs after the asynchronous search completes.
cons.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(Contacts_SearchCompleted);
//Start the asynchronous search.
cons.SearchAsync("0109", FilterKind.PhoneNumber, "State String 5");
}
void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
{
try
{
//Bind the results to the user interface.
ContactResultsData.DataContext = e.Results;
}
catch (System.Exception)
{
//No results
}
if (ContactResultsData.Items.Any())
{
ContactResultsLabel.Text = "results";
}
else
{
ContactResultsLabel.Text = "no results";
}
}
但FilterKind.PhoneNumber
只有当它具有至少最后6位数字的电话号码的匹配工作。
任何想法如何实现这一目标?
顺便说一声我是一个初学者。