3
votes

I am using Windows 8.1 and Visual Studio 2013. As far as I know, everything is update to date. So what I wanted is to fetch contact list, but I am not able to the that even after googling.

According to MSDN, all I have to do is put using Microsoft.Phone.UserData and after that I can happily get contacts. The problem is, I can't, because there is an error which says that Microsoft.Phone.* doesn't exist.

Am I missing something or what. According to site above, it applies to Windows Phone 8 and Windows Phone Silverlight 8.1 | Windows Phone OS 7.1.

P.S. It's about blank app (Windows Phone) project

2
Which kind of project did you create ? Maybe you are you targeting Windows Phone 8.1 ? As the article mentions, this is not supported on Windows Phone 8.1 (Windows Phone Silverlight 8.1 is not the same)Thierry
Yes it's windows phone 8.1 app. In Windows phone silverlight 8.1 works fine now. Is there any particular reason why this doesn't work (any more) in windows phone 8.1.letx44
Windows Phone 8.1 shares for a large part the same WinRT APIs as Windows 8/8.1. So things have to be done the same way as for Windows Store applications. The best way when you look for how to implement something for Windows Phone 8.1, is to look at the Windows 8 documentation, and see if it also applies to Windows Phone 8.1 (it's often, but not always, the case)Thierry
@Thierry after reading the Contact class, I think you're correct. Would you consider to post your comment as an answer?Andrew T.

2 Answers

2
votes

You are looking at the tutorial for Windows Phone 8 as against the fact that most probably you are using WinRT for Windows phone 8.1

You need to use the ContactStore class by using the ContactManager class. Here is a code snippet from MSDN

public async void FindContacts(string searchText)
{
    ContactStore contactStore = await ContactManager.RequestStoreAsync();

    IReadOnlyList<Contact> contacts = null;

    if(String.IsNullOrEmpty(searchText))
    { 
        // Find all contacts
        contacts = await contactStore.FindContactsAsync();
    }
    else
    {
        // Find contacts based on a search string
        contacts = await contactStore.FindContactsAsync(searchText);
    }

    MyContactListBox.ItemsSource = contacts;
}

In case you want to target older versions of windows phone you might want to read this

In case there is a confusion in regards to what version of SDK do I use for targeting a specific version of windows phone , here is the help.

1
votes

I have had the same issue, think it might be because if I look for the Microsoft.Phone class, I find it in a 8.0 directory. In my case

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0\

I then just referenced it by browsing for the file. I'm not sure what you're intending to use it for, and if the classes will be compatible with 8.1. But I hope this helps.