Share via


Exercise 2: Create a Silverlight Application and a Framework for Deployment

In this exercise you will add a Silverlight project to an existing solution and create a framework to deploy the Silverlight application to a SharePoint farm.

Task 1 – Adding a new Silverlight Application to the Existing Solution

  1. Using Visual Studio, open the starter solution from <Install>\Labs\AccessingSPUsingQueryWebServiceSource\Begin\ SilverlightQueryWebService.sln.
  2. Right-click the SilverlightQueryWebService solution file in the Solution Explorer and select Add New Project.
  3. Select Silverlight in the left-hand pane and Silverlight Application in the center pane.
  4. Name the project Silverlight.QueryWebService.

    Figure 4

    Create a new Silverlight application project

  5. Click OK.

Task 2 – Adding a SharePoint Module to Deploy the Silverlight Xap.

  1. Right-click on SharePoint.Client.QueryWebService project in Solution Explorer and select Add -> New Item.
  2. Select the Module project item and name the Module item Silverlight.
  3. Click Add.
  4. Right-click on Sample.txt in the Solution Explorer and select Delete to remove the sample file.
  5. Right-click the Silverlight project item in Solution Explorer and select Properties.
  6. Select Project Output References in the Properties pane.

    Figure 5

    Properties pane

  7. Click the ellipse button.
  8. Click Add in in the Project Output References dialog.

    Figure 6

    Project Output References dialog

  9. Right-click the Silverlight project item in Solution Explorer and select Add -> Existing Item.
  10. Set the Project Name property to Silverlight.QueryWebServices.
  11. Set the Deployment Type property to ElementFile. This will include the output of the Silverlight.QueryWebService project in the SharePoint module for deployment.

    Figure 7

    Project Output References dialog

  12. Click OK.
  13. Right-click on the Elements.xml file in the Silverlight module project item and select Open.
  14. Add Url="SiteAssets" to the Module element
  15. Add Type="GhostableInLibrary" to the File element.
  16. Set the Url attribute located in the File element equal to "Silverlight.QueryWebService.xap".

Task 3 – Adding a SharePoint Module to a Custom Aspx Page to Display the Silverlight Application in a Silverlight Web Part.

  1. Right-click on SharePoint.Client.QueryWebService project in Solution Explorer and select Add -> New Item…
  2. Select the Module project item and name the Module item CustomPages.
  3. Click Add.
  4. Right-click on Sample.txt in the Solution Explorer and select Delete to remove the sample file.
  5. Right-click on the CustomPages project item and select Add -> Existing Item
  6. Select QueryWSDemo.aspx located at <Install>\Labs\AccessingSPUsingQueryWebService\Source\SupportingFiles.
  7. Right-click on the Element.xml file located in the CustomPages module and select Open.
  8. Replace the Xml in Elements.xml with the Xml included in CustomPagesElements.xml file located at <Install> \Labs\AccessingSPUsingQueryWebService\Source\SupportingFiles.

Exercise 2 Verification

In order to verify that you have correctly performed all steps of exercise 1, proceed as follows:

Verification 1

In this verification, the custom Aspx page will deploy and contain a Silverlight Web Part. The Silverlight application has no user interface and will not display any visible ui.

  1. Right-click the solution name in Solution Explorer and select Deploy Solution.
  2. Navigate to https://intranet.contoso.com/queryWSDemo.aspx .
  3. Verify the page loads and contains the Silverlight Query Web Service Web Part.

    Figure 8

    Silverlight Query Web Service Web Part