Getting Started with Silverlight in SharePoint 2010

Silverlight is a fast evolving and powerful technology for building Rich Internet Applications (RIA).  Integrating Silverlight to SharePoint sites allows for the building of very responsive and interactive interfaces as well as support for out-of-browser applications and a deep support for video integration.
Silverlight integration is already included in SharePoint 2010 – when you try to create a new list, library, discussion board or a simple page  without Silverlight installed  you will find the traditional SharePoint Create page.
silverlight1 Getting Started with Silverlight in SharePoint 2010
However with Silverlight installed, you will have a richer feature set with options to filter, categorize and even to configure the settings:
silverlight2 Getting Started with Silverlight in SharePoint 2010
Silverlight applications can be embedded with SharePoint 2010 in serveral ways:
  • SharePoint 2010 Service integration with Silverlight
  • Client object model with Silverlight
  • Rendering data with Silverlight
  • REST services with Silverlight
SharePoint 2010 Service integration with Silverlight – SharePoint 2010 has numerous built-in web services. You can also create your own web service and use a Silverlight application to implement this service. Generally asynchronous execution is required and the results are retrieved in xml form and then parsed.
Client object model with Silverlight – The Silverlight client object model uses asynchronous query execution so that delegates for callback methods are passed as parameters in the ExecuteQueryASync method.  If you wish to use the Silverlight object model, create a Silverlight application in Visual Studio, then open the default Page.xaml.cs file and add code in the page class. Build the project and upload it as .xap package to a document library. Finally, add the Silverlight web part to the site page and then point the URL of the Web Part to the .xap file that you uploaded to the document library.
Rendering data with Silverlight – Data can be rendered with Silverlight by passing initiation parameters through the init params method of Silverlight.
REST services with Silverlight – REST services help create strongly typed object sin SharePoint using OOP and ATOM.

Publishing a Silverlight Application on a SharePoint Site

To publish a Silverlight application on a SharePoint site, open Visual Studio 2010, select Silverlight Application under Installed Templates and enter a  name for your application:
silverlight3 Getting Started with Silverlight in SharePoint 2010
Uncheck the checkbox in the prompt that asks if you wish to create a web application to host the Silverlight application. As SharePoint itself acts as the host, hosting Silverlight on a separate application is not necessary. You can customize your instance of Silverlight application by editing the MainPage.xaml file.
silverlight4 Getting Started with Silverlight in SharePoint 2010
Save the project and close it. Restart Visual Studio as an Administrator.  Right click the solution and select Add -> New Project.  Then select SharePoint –> 2010 as the project type. In the Add New Project dialog, select Empty SharePoint Project.
silverlight5 Getting Started with Silverlight in SharePoint 2010
In the SharePoint customization wizard dialog, leave the sandboxed solution checked and then click OK. In the Solution Explorer, right click the SharePoint project and select Add -> New Item.  In the Add New Item dialog, select Module and then click Add.
silverlight6 Getting Started with Silverlight in SharePoint 2010
Next, right click the new Module and select Properties. The Properties window will be displayed. Click  Project Output References and then click the ellipse button (…). The Project Output References dialog will be displayed. Next, click Add , expand the deployment location property to change the Project Name to SilverlightApplication and the Deployment Type to ElementFile.
silverlight7 Getting Started with Silverlight in SharePoint 2010
Now expand the module that was created in the SharePoint project and delete the Sample.txt file. Edit the Elements.xml file to include the xap file that is generated by the Silverlight application.
silverlight8 Getting Started with Silverlight in SharePoint 2010
The application is now ready for deployment, right click the SharePoint project and select Set as Startup Project. Then hit F5 key on your keyboard to built and deploy to your local SharePoint site. Click the Insert tab in the Editing Tools. Select the Media and Content category in the left column and then Silverlight Web Part. Finally, click Add .
silverlight9 Getting Started with Silverlight in SharePoint 2010
The Silverlight Web Part dialog will be displayed. Enter the value from the Url field with a leading slash in the Elements.xml file, for example :/_catalogs/masterpage/SilverlightApplication.xap
Simply ignore the message that it could not download the xap file.  Finally, click  Save and your Silverlight application is integrated into your SharePoint site.
silverlight10 Getting Started with Silverlight in SharePoint 2010

Related Articles:

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

One Response to “Getting Started with Silverlight in SharePoint 2010”

  1. Nice Getting Started Tutorial for Silverlight with Sharepoint 2010