Like with the .NET managed
code and JavaScript CSOMs, CSOM libraries are available for both
Windows Phone and Silverlight. This availability allows developers to
use the same common library and patterns to integrate Windows Phone
mobile apps in almost the same way they would in a JavaScript-based
SharePoint-hosted application. The reason mobile apps are not exactly
the same is because a developer must take into consideration a few
additional things in mobile scenarios that are not as prevalent in
other types of applications. For example, you must think about
scenarios where the phone is not connected to a data network. Will it
support offline data sync? What about on different types and speeds of
data network? How do you connect to the SharePoint Server while you are
not on the same network and possibly behind a firewall? Finally, what
about your authentication options? These are all things you must
consider and design for in your mobile applications.
The Windows Phone CSOM assists you with some of
these issues; however, many others are up to you as a developer to work
out how you want to support them. The Windows Phone CSOM offers support
for new authentication options by supporting forms authentication,
basic authentication, and Office 365 authentication. Previously, there
wasn’t a CSOM library that would run on Microsoft’s Windows Phone, and
communication was limited to Web service calls. Additionally,
authentication was very hard, nearing impossible for many. Additional
products that facilitated transforming forms authentication to Windows
authentication put it out of reach for most. The new Windows Phone CSOM
solves this problem by wrapping each of the authentication options for
you so that you don’t have to do the plumbing work. However, they still
might offer some challenges such as not supporting Windows
authentication (NTML), which many on-premises SharePoint
implementations rely on. However, the authentication options that are
supported certainly cover many of the scenarios that are more broadly
applicable in mobile scenarios where the user is out of the office and
connecting over the Internet.
Additionally, the Microsoft SharePoint SDK for
Windows Phone 7.1 adds support in Visual Studio 2012 for SharePoint
mobile project templates that allow you to get building applications
faster with some convenient templates you can extend and build on.
The improvements offered for Windows Phone mobile applications with the 2013 release include:
- Visual Studio templates to get you started
- SharePoint Client-Side Object Model support
- Extended authentication support (forms, basic, Office 365)
Setup
To start building Windows Phone applications that communicate with SharePoint you need the following components:
- Visual Studio 2010
- Windows 7 or Vista
- A SharePoint Server on premises or an Office 365 site
- SharePoint SDK for Windows Phone 7.1
- Windows Phone SDK 7.1
NOTE:
SharePoint does not support being run on a Windows 7, Windows 8, or
Vista operating system. If you don’t have access to another machine
running SharePoint 2013 then a good option is to sign up for Office 365.
After you have the requisite applications and SDKs installed you can find the CSOM libraries for referencing in the following:
%ProgramFiles (x86)%\Microsoft SDKs\SharePoint\v15.0\Phone\v7.1\Libraries
This directory includes the three main DLLs you need:
- Microsoft.SharePoint.Client.Phone.dll
- Microsoft.SharePoint.Client.Phone.Runtime.dll
- Microsoft.SharePoint.Phone.Application.dll
Much like the Managed CSOM, you must reference these DLLs in your application to get access to the CSOM types required.
You may also start your project from one of the provided Visual Studio templates:
- The Windows Phone empty SharePoint application
- The Windows Phone SharePoint List application
These templates, by default, reference the
required CSOM assemblies for you. The empty application, as its name
suggests, gives you a blank canvas to create your application, whereas
the list application template lays down some starter files to get you
started building an app that reads and saves data in a SharePoint list.
It walks you through a series of steps in a wizard that allows you to
pick your SharePoint site, list, and fields with which you want to
interact and then builds the appropriate views and view models using a
Model-View-ViewModel (MVVM) design pattern (see Figure 1).