150 likes | 163 Views
Module 10 Developing Silverlight Applications for SharePoint. Module Overview. Creating Silverlight Applications for SharePoint 2010 Deploying and Debugging Silverlight Applications for SharePoint 2010 Lab: Developing Silverlight Applications by Using the SharePoint Client Object Model.
E N D
Module 10 Developing Silverlight Applications for SharePoint
Module Overview • Creating Silverlight Applications for SharePoint 2010 • Deploying and Debugging Silverlight Applications for SharePoint 2010 • Lab: Developing Silverlight Applications by Using the SharePoint Client Object Model
Lesson 1: Creating Silverlight Applications for SharePoint 2010 • Silverlight Integration with SharePoint 2010 • SharePoint Client Object Model DLLs for Silverlight • Accessing SharePoint Objects and Data in Silverlight Applications • Asynchronous Communication Between Silverlight and SharePoint
Silverlight Integration with SharePoint 2010 • Microsoft Office SharePoint Server 2007 object model only available from a server in the farm • SharePoint Web services • You could create your own client and/or server objects for Silverlight • SharePoint Server 2010 provides the client object model • Silverlight-specific implementation • SharePoint Server 2010 provides Silverlight Web Parts
SharePoint Client Object Model DLLs for Silverlight • Silverlight implementation • Rationale • DLL location • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin • DLL deployment • With XAP file
Accessing SharePoint Objects and Data in Silverlight Applications • ClientContext objects • Initializing to current SharePoint site collection • Adding using statements for Microsoft.SharePoint.Client and System.Threading • App.xaml.cs • User control • Initializing to remote SharePoint site • Same pattern as the .NET implementation of the SharePoint client object model for other objects private void Application_Startup(object sender, StartupEventArgs e) { ApplicationContext.Init(e.InitParams, SynchronizationContext.Current); this.RootVisual = new MainPage(); } ... clientCtx = new ClientContext(ApplicationContext.Current.Url); ...
Asynchronous Communication Between Silverlight and SharePoint • Rationale • Do not block the main UI thread • ExecuteQueryAsync method • Success callback procedure • Failure callback procedure • Updating the user interface from callback procedures • Switch thread context back to main UI thread • Code sample
Lesson 2: Deploying and Debugging Silverlight Applications for SharePoint 2010 • Deploying Silverlight Applications to SharePoint • Displaying Silverlight Applications in SharePoint 2010 Sites • Developing Custom Web Parts for Displaying Silverlight Applications • Debugging Silverlight Applications
Deploying Silverlight Applications to SharePoint • Deploying Silverlight XAP files • ClientBin folder • SharePoint document library • Deploying other assets • ClientBin folder • SharePoint document library
Displaying Silverlight Applications in SharePoint 2010 Sites • Built-in Silverlight Web Part • Media category • Silverlight Web Part properties • Width and Height • Initiation parameters • Embedding client-side HTML for rendering Silverlight applications <object data='data:application/x-silverlight-2' type='application/x-silverlight-2'>" <param name='source' value='_layouts/clientbin/myapp.xap'/>" <param name=initParams' value='bg=#FFFFFF,fg=#0000FF/>" </object>
Developing Custom Web Parts for Displaying Silverlight Applications • Built-in Silverlight Web Part supports parameters • In some cases you might not want to enable users to supply the parameters • Develop your own Web Part so that you can supply your own parameters directly • Develop your own Web Part so that you can include client-side error-handling routines protected override CreateChildControls() { string renderSLApp = "<div id='mySilverlightHost'>" + "<object data='data:application/x-silverlight-2'" + " type='application/x-silverlight-2'>" + "<param name='source' value='_layouts/clientbin/myapp.xap'/>" + "<param name=initParams' value='bg=#FFFFFF,fg=#0000FF/>" + "</object></div>"; this.Controls.Add(new LiteralControl(renderSLApp)); }
Debugging Silverlight Applications • Silverlight applications run in the user’s browser • No server-side process to attach to • Attaching the debugger • IExplore.exe • Silverlight debug setting
Lab: Developing Silverlight Applications by Using the SharePoint Client Object Model • Exercise 1: Creating a Silverlight Application • Exercise 2: Developing the Silverlight Application Logon information Estimated time: 60 minutes
Lab Review • How did Silverlight communicate with SharePoint? • Was the communication synchronous or asynchronous? • Why? • Where did you deploy the Silverlight XAP file? • How was the Silverlight application displayed in SharePoint? • How did you render media files in Silverlight?
Module Review • In this module, you have learned to: • Develop and deploy Silverlight applications to SharePoint • Display Silverlight applications in SharePoint 2010 sites