Is it posible to get a contact without using class Contacts and his SearchAsync method? I proceed to explain my problem.
I have an ObservableCollection
private ObservableCollection<ContactPictureItemModel> _ContactPictures;
being ContactPictureItemModel something like this
public class ContactPictureItemModel
{
private string _Email;
private byte[] _Picture;
private string _DisplayName;
public ContactPictureItemModel(string email, byte[] picture, string displayName)
{
this._Email = email;
this._Picture = picture;
this._DisplayName = displayName;
}
public string Email
{
get { return _Email; }
set { _Email = value; }
}
public byte[] Picture
{
get { return _Picture; }
set { _Picture = value; }
}
public string DisplayName
{
get { return _DisplayName; }
set { _DisplayName = value; }
}
}
Every object in this ObservableCollection represents a contact picture that application has “cached” everytime user has picked a contact from EmailAddressChooserTask.
I need when calling this method
public ContactPictureItemModel GetContactPictureItem(string email, string displayName)
{
ContactPictureItemModel contactPictureResult;
foreach (ContactPictureItemModel contact in ContactPictures)
{
if (email.Equals(contact.Key))
{
contactPictureResult = contact;
break;
}
}
if (contactPictureResult == null)
{
//Retrieve contact using "email" parameter
}
return contactPictureResult;
}
and contact is not found in the ObservableCollection, to be able to get the contact using parameters “email” and “displayName” without using any async task. I need the function retrieves the ContactPictureItemModel object.
Is that possible?
Thanks!
It’s not possible to synchronously access a contact, since there’s no API for it.
You could create the view model in a “loading” state and then “fill it in” when the async method completes. Just make sure the model class implements
INotifyPropertyChanged