Hands-On Lab
Accessing SharePoint using Silverlight Out-
of-Box Application
Lab version: 1.0.0
Last updated: 11/5/2011
CONTENTS
OVERVIEW ................................................................................................................................................... 2
EXERCISE 1: RETRIEVE AND DISPLAY TASK ITEMS FROM INTRANET.CONTOSO.COM. ............... 4
Task 1 – Creating Task Items in the Intranet.contoso.com Task List. ................................................... 4
Task 2 – Creating and Deploying the Silverlight Web Part Used to Retrieve and Display the Tasks. ... 4
Exercise 1 Verification ........................................................................................................................... 6
EXERCISE 2: CONFIGURE THE SILVERLIGHT APPLICATION FOR OOB ............................................ 6
Task 1 – Enabling Out-of-Browser Support for the Application............................................................ 7
Task 2 – Configuring Out-of-Browser Settings. ..................................................................................... 7
Task 3 – Deploying the OOB Application. ............................................................................................. 8
Exercise 2 Verification ........................................................................................................................... 9
EXERCISE 3: CREATE OUTLOOK TASKS USING THE OOB SILVERLIGHT APPLICATION ............... 9
Task 1 – Adding Code to Create an Outlook Task from the Displayed Task. ........................................ 9
Task 2 – Modifying the User Interface to Display a Message When Running in Browser. ................. 10
Task 3 – Removing, Reinstalling and Testing the OOB Application. ................................................... 11
Exercise 3 Verification ......................................................................................................................... 13
SUMMARY .................................................................................................................................................. 13
Overview
Silverlight applications can run out of browser (OOB). Silverlight OOB applications hosted by the client
can use SharePoint remote APIs to access SharePoint data and services. OOB applications can run in full
trust unlike in browser applications. These applications have greater access to the host system and the
.Net Base Class Libraries.
Objectives
This lab will demonstrate creating Outlook tasks from SharePoint tasks using a Silverlight OOB
application.
Create an in browser Silverlight application to retrieve and display tasks.
Enable and configure the application to run out of browser.
Create Outlook tasks from the OOB application.
System Requirements
You must have the following items to complete this lab:
2010 Information Worker Demonstration and Evaluation Virtual Machine
Microsoft Visual Studio 2010
Visual Studio 2010 SharePoint Power Tools
Silverlight 4 Toolkit
Silverlight WebPart
Setup
You must perform the following steps to prepare your computer for this lab...
1. Download the 2010 Information Worker Demonstration and Evaluation Virtual Machine from
http://tinyurl.com/2avoc4b and create the Hyper-V image.
2. Install the Visual Studio 2010 Silverlight Web Part. The Silverlight Web Part is an add-on to
Visual Studio 2010 and can be downloaded from http://code.msdn.microsoft.com/vsixforsp.
3. Install the Silverlight 4 Toolkit located at http://silverlight.codeplex.com/
4. Install the Visual Studio 2010 SharePoint Power Tools located at
http://visualstudiogallery.msdn.microsoft.com/en-us/8e602a8c-6714-4549-9e95-f3700344b0d9
Exercises
This Hands-On Lab comprises the following exercises:
1. Retrieve and Display Task Items from intranet.contoso.com
2. Configure the Silverlight Application for OOB
3. Create Outlook Tasks using the OOB Silverlight Application
Estimated time to complete this lab: 30 minutes.
Starting Materials
This Hands-On Lab includes the following starting materials.
Visual Studio solutions. The lab provides the following Visual Studio solutions that you can use
as starting point for the exercises.
◦ AccessingSPSilverlightOTB\Source\Begin\OOB_SharePointTasks\OOB_SharePointT
asks\ OOB_SharePointTasks.sln: This soution is a a Silverlight Web Part with the
starter code commented out.
Note: Inside each exercise folder, you will find an end folder containing a solution with the
completed lab exercise.
Exercise 1: Retrieve and Display Task
Items from intranet.contoso.com.
In this exercise you deploy a Silverlight Web Part that will connect to intranet.contoso.com and display
tasks from a task list.
Task 1 – Creating Task Items in the Intranet.contoso.com Task List.
1. Using Internet Explorer navigate to http://intranet.contoso.com/ Lists/Tasks/AllItems.aspx.
2. Click Add new item link.
3. Enter a title of Title 1.
4. Enter a Start Date
5. Enter a Due Date.
6. Click Save.
7. Repeat steps 2-6 to create two additional tasks titled “Task 2” and “Task 3”.
8. Close Internet Explorer.
Task 2 – Creating and Deploying the Silverlight Web Part Used to Retrieve and Display the Tasks.
1. Using Visual Studio open the starter solution named OOB_SharePointTasks from
AccessingSPSilverlightOTB\source\Begin\OOB_SharePointTasks folder. The
OOB_SharePointTasks project contains a Silverlight Web Part that will display tasks from a Task
list.
2. Using the Solution Explorer, expand the OOB_SharePointTasks project.
3. Expand the ViewModels folder.
4. Right-click SharePointTaskSyncViewModel.cs and select Open.
5. Locate the existing GetSharePointTasks method
6. Add Snippet 10.1.1 to create the body of the GetSharePointTasks method.
Figure 1
GetSharePointTasks method
7. Notice the method clears the existing ObservableCollection and creates a DataContext to query
the Task list. The method defines a query and calls the BeginExecute method.
8. Locate the existing DataContextResponseCallback method.
9. Add snippet 10.1.1.2 to create the body of the DataContextResponseCallback method.
10. Notice this method executes the query against a Rest service proxy and creates a new SPTask
object to the ObservableCollection. The ObservableCollection, SharePointTasks, is the data
store for the databound list in the user interface.
Figure 2
DataContextResponseCallback method
11. Save and close SharePointTaskSyncViewModel.cs
12. Build and deploy the solution by clicking F5.
13. After Visual Studio launches Internet Explorer, navigate to
http://intranet.contoso.com/SitePages/oob_SharePointTasksWebPartPage.aspx .
14. Click the GetTasks button.
Figure 3
Web Part page
Exercise 1 Verification
In order to verify that you have correctly performed all steps of exercise 1, proceed as follows:
Verification 1
In this verification, the Silverlight Web Part will display the three tasks created in the Task list..
1. With the solution running in debug mode, use Internet Explorer to navigate to
http://intranet.contoso.com/SitePages/oob_SharePointTasksWebPartPage.aspx.
2. Verify the Silverlight application displays in the Web Part.
3. Click the GetTasks button.
4. Verify the three tasks displays in the Silverlight application.
Exercise 2: Configure the Silverlight
Application for OOB
In this exercise, you will redeploy an existing Web Part to intranet.contoso.com after you enable the
Silverlight application to run out of browser.
Task 1 – Enabling Out-of-Browser Support for the Application
Running out of browser requires the Silverlight application to be enabled for OOB.
1. Right-click on the OOB_SharePointTasks in Solution Explorer and select Properties
Figure 4
Properties in Solution Explorer
2. Select the Silverlight tab.
3. Select Enable running application out of the browser checkbox to enabled OOB
Figure 5
Enable running application out of the browser checkbox
Task 2 – Configuring Out-of-Browser Settings.
The Silverlight manifest contains settings to configure the OOB experience. In this task you will configure
the OOB settings.
1. Right-click on the OOB_SharePointTasks in Solution Explorer and select Properties
2. Select the Silverlight tab.
3. Click the Out-of-Browser button to display the OOB settings.
Figure 6
Out of Browser Settings dialog
4. Set Window Title to SharePoint Tasks
5. Set Width to 375.
6. Set Height to 450.
7. Verify Show Install menu is selected
8. Verify Require elevated trust when running outside the browser is selected.
9. Silverlight runs under partial trust. Not all OOB applications require elevated trust. In this demo,
we will be creating tasks in Outlook. This will require full trust.
10. Verify the Window Style is set to Default. Selecting another Window Style may require you to
create a method to close the window. The default style window supports closing the window.
11. Click OK.
Task 3 – Deploying the OOB Application.
OOB applications installs from a host web page. In this task, you will redeploy the Silverlight Web Part
and Silverlight application and install the OOB application on the client.
1. Right-click SharePointTask propject in Solution Explorer and click Set as StartUp Project.
2. Build and deploy the solution by clicking F5.
3. After Visual Studio launches Internet Explorer, navigate to
http://intranet.contoso.com/SitePages/oob_SharePointTasksWebPartPage.aspx .
4. Click the GetTasks button to verify the application can retrieve tasks.
5. Right-click on the Silverlight application and select Install SL SharePoint Tasks onto the
computer.
Figure 7
Install SL SharePoint Tasks onto this computer option
6. Close Internet Explorer. The application will be running out of browser. The application will have
an shortcut located on the desktop
7. Click the GetTasks button.
8. Verify the three tasks displays in the Silverlight application.
9. Close the OOB application.
Exercise 2 Verification
In order to verify that you have correctly performed all steps of exercise 2, proceed as follows:
Verification 2
In this verification, the tasks have been completed correctly if the OOB Silverlight Application displays
the same tasks from intranet.contoso.com when running in browser and out of browser.
Exercise 3: Create Outlook Tasks using
the OOB Silverlight Application
In this exercise you will modify the existing Silverlight application to create Outlook tasks from the
displayed SharePoint tasks. This will require full trust which will not run in broswer. You will use
IsRunningOutOfBrowser property to display a message to the user when running inside the browser.
Task 1 – Adding Code to Create an Outlook Task from the Displayed Task.
In this task, you will modify the existing code to create a Outlook task from the selected task.
1. Using the Solution Explorer, expand the OOB_SharePointTasks project.
2. Expand the ViewModels folder.
3. Right-click SharePointTaskSyncViewModel.cs and select Open.
4. Using snippet 10.1.1.3 to add a method named AddToOutlook to create tasks from the selected
task.
Figure 8
AddToOutlook method
5. Save and close SharePointTaskSyncModel.cs.
Task 2 – Modifying the User Interface to Display a Message When Running in Browser.
In this task, you will review the user interface Xaml and modify the existing code to display a message
when running in browser.
1. Using the Solution Explorer, expand the OOB_SharePointTasks project.
2. Right-click MainPage.xaml in Solution Explorer and select Open
3. Review the Xaml used to create the UI. Notice the Xaml includes a canvas used to display the
tasks and a canvas used to display a message to the user that the application cannot run in
browser.
4. Right-click on the Xaml in the code pane and select View Code to display MainPage.Xaml.cs.
5. Locate the MainPage contructor and use the IsRunningOutOfBrowser property to control which
canvas to display. Use Snippet 10.1.1.4 to include the code to set the user interface.
Figure 9
IsRunningOutOfBrowser property
6. Locate btnAdToOutlook method.
7. Add code to call the ViewModel’s AddToOutlook method. Use Snippet 10.1.1.5 to add the
code.
Figure 10
btnAddToOutlook_Click method
8. Save the project.
Task 3 – Removing, Reinstalling and Testing the OOB Application.
In this task, you will remove the Silverlight application from the client. You will then redeploy the
modified Silverlight Web Part and Silverlight application and reinstall. The Silverlight will now add tasks
to Outlook.
1. Locate the SL SharePoint Tasks shortcut on the client desktop.
2. Double-click the shortcut to start the OOB application
Figure 11
SL SharePoint Tasks icon
3. Right-click on the application and select Remove this application.
4. Click Yes when prompted to remove the application. The application is removed from the
client.
Figure 12
Remove this application option
5. Right-click on the solution in Solution Explorer and click Deploy.
Figure 13
Deploy Solution in Solution Explorer
6. Using Internet Explorer navigate to
http://intranet.contoso.com/SitePages/oob_SharePointTasksWebPartPage.aspx. Notice the
new interface display a message to the user.
7. Right-click on the Silverlight application and select Install SL SharePoint Tasks onto the
computer.
8. Close Internet Explorer.
9. Open Outlook on the client machine where the OOB application is installed.
10. Click on Tasks in the Outlook Navigation pane to display any tasks already saved in Outlook.
Figure 14
Tasks in the Outlook Navigation pane
11. Click the GetTasks button on the OOB Silverlight client.
12. Click a task’s Add To Outlook button.
13. Verify the application has added the task to Outlook.
Figure 15
Added task in Outlook
Exercise 3 Verification
In order to verify that you have correctly performed all steps of exercise 3, proceed as follows:
Verification 3
Clicking on a task’s Add to Outlook button and verifying the task has been added to Outlook verifies the
tasks have been performed correctly.
Summary
Silverlight supports running Out of the Browser applications. These applications can be added and
removed to the client machine by the user. OOB are enabled and confgured to run as OOB and have
properties and events to support development of OOB applications. OOB applications have access ot
the .Net Base Class Libraries and can run in Full Trust. OOB applications are not specific to SharePoint
although remote access to SharePoint data and services are supported.