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位數字的電話號碼的匹配工作。
任何想法如何實現這一目標?
順便說一聲我是一個初學者。