Reputation: 6142
I have 4 accounts set in my People Hub (Windows Live Id, LinkedIn, Twitter and Facebook). I have unchecked in "People Hub\filter my contact list" twitter and facebook accounts so now I don't see them in my address book - good. But when I am trying to obtain them in code by:
var contacts = new Microsoft.Phone.UserData.Contacts();
contacts.SearchCompleted += (s, e) => ...
contacts.SearchAsync(String.Empty, FilterKind.None, null);
I receive all of the my accounts including Twitter and Facebook ones - How can I prevent it? I have found property contacts.Accounts
but it returns {Windows Live Id, Facebook}
Upvotes: 1
Views: 781
Reputation: 6723
Each of the Contacts that are returned also have an Accounts property
http://msdn.microsoft.com/en-us/library/microsoft.phone.userdata.contact.accounts(v=vs.92).aspx
You could filter your result using
contacts.SearchCompleted += (s,e) => e.Results.Where(c=>MyFilter(c.Accounts))
Remember that some contacts might be merges of info from multiple accounts.
var allAccounts = Contacts.Accounts;
var interestingAccounts = allAccounts.Where(x=>x.Name!="Twitter") // or x.Kind
bool Myfilter(IEnumerable<Account> accounts)
{
return accounts.Intersect(interestingAccounts).Any();
}
EDIT:
bool Myfilter(IEnumerable<Account> accounts)
{
return accounts.Intersect(Contacts.Accounts).Any();
}
Upvotes: 2