With SharePoint 2013, Microsoft has included a set of Windows Phone assemblies that will allow you to quickly build native Windows Phone applications that can communicate and interact with data in SharePoint. The two assemblies you need to reference in your WP application are Microsoft.SharePoint.Client.Phone and Microsoft.SharePoint.Client.Phone.Runtime. Both assemblies are located in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ClientBin.
Authentication to the SharePoint site is handled using the Authenticator class. Windows Phone apps with SharePoint supports four authentication modes: Windows Authentication (Default), Forms Authentication, Anonymous, and using Microsoft Online. I have not tested the Microsoft Online-based Authentication but I believe it's used in conjunction with the Microsoft.SharePoint.Client.BrowserLogin class (in the Runtime assembly), which is an application page that will load when using this type of authentication.
For Windows Authentication, note that either Forefront UAG must be used or the web application must be configured to use Basic Authentication.
The following is an example of retrieving data from a SharePoint list:
public void LoadData()
currentDispatcher = Application.Current.RootVisual.Dispatcher;
//obviously, these shouldn't be hard-coded.
ClientContext context = new ClientContext(new Uri("http://url-to-sharepoint-site"));
context.Credentials = new Authenticator("Username", "Password",
Site site = context.Site;
Web web = site.RootWeb;
List productsList = web.Lists.GetByTitle("Products");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><RowLimit>100</RowLimit></View>";
productItems = productsList.GetItems(camlQuery);
this.IsDataLoaded = true;
The important part of the code is that the ClientContext.Credentials is set to an instance of the Authenticator class.
This is what the success handler looks like:
void ClientRequestSucceededEventHandler(object sender, ClientRequestSucceededEventArgs e)
foreach (var item in productItems)
string trimmedDescription = item["Description"].ToString();
if (trimmedDescription.Length > 150) trimmedDescription = trimmedDescription.Substring(0, 149) + " ...";
Title = item["Title"].ToString(),
Description = trimmedDescription,
ImageUrl = new Uri((item["Image"] as FieldUrlValue).Url, UriKind.Absolute),
Color = item["Color"].ToString()
this.IsDataLoaded = true;
When the code executes, this is what the Phone app looks like:
This data is being pulled from a SharePoint list:
With Windows Phone apps, there is full support for CRUD operations on list data. This also includes external lists. There is also support for push notifications, which I'll cover in the next blog post. I’ll also be sharing the full source code for this little app in the next post.