when I test my app in emulator the contact list comes out. But when I test in device contact list does not show. I am using HTC radar.
Here is my code snippet :
AddressChooserTask addressTask;
public ContactsPage()
{
InitializeComponent();
addressTask = new AddressChooserTask();
addressTask.Completed += new EventHandler<AddressResult>(addressTask_Completed);
}
void addressTask_Completed(object sender, AddressResult e)
{
if (e.TaskResult == TaskResult.OK)
{
string displayName = e.DisplayName;
Contacts contacts = new Contacts();
contacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(contacts_SearchCompleted);
contacts.SearchAsync(displayName, FilterKind.DisplayName, null);
}
}
private void btnChooseContacts_Click(object sender, RoutedEventArgs e)
{
addressTask.Show();
}
please anyone get me out of the problem! Thanks in advance !
There’s a lot of strange things you do.
1st, you are assigning the same object over and over again in your foreach loop. So if the last item is blank, the resulting text boxes will be blank.
2nd, you are trying to reference a property that might be null. The FirstOrDefault() can return null, so check for that.
3rd. You really should use databinding and bind the result to a listbox (or other databindable UI element) instead.