Shawn Wildermuth AgiliTrain Microsoft MVP (C#), MCSD Silverlight in SharePoint WebParts You got peanut butter in my chocolate
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Who Am I? Shawn Wildermuth ▫ ▫ C# MVP, MCSD, MCT, INETA Speaker, Author AgiliTrain ▫ Silverlight for SharePoint – Atlanta, June 2-4, 2009 ▫ Silverlight Tour – Atlanta, July 20-22, 2009 ▫ Advanced Silverlight – Atlanta, August 3-4, 2009
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Agenda Why Silverlight? SharePoint Integration ▫ Linking Projects ▫ Hosting in SharePoint ▫ Using Web Services ▫ Debugging
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 What’s SharePoint? I am not a SharePoint Expert… ▫ …Some of the Techniques Here May Be Hacky… ▫ Goal is to show how it *can* work ▫ So you can apply it to your exceptional SharePoint Skills
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 SharePoint
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Why Silverlight in SharePoint Leave to SharePoint (and Web) What They Do Well ▫ Silverlight for Islands of Content ▫ Where Graphics and Interactivity Helps ▫ Don’t Overuse it
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Using Silverlight in WebPart Project Can Create Silverlight in Same Solution ▫ No Official Linking ▫ Must Do Manually Post-Build, Shared File, MSBuild ▫ Add XAP to WebPart XML file for Deployment
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Using Silverlight in WebPart Project WebPart.xml ▫ May be better as separate module <File Path="SilverlightTaskViewer.webpart" Url="SilverlightTaskViewer.webpart" Type="GhostableInLibrary" /> <File Path="SilverlightTasksWidget.xap" Url="SilverlightTasksWidget.xap" Type="GhostableInLibrary" />
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 New Silverlight Web Part
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Hosting in SharePoint WebPart Can Create HTML Code ▫ LiteralControl and ObjectTag public class SilverlightTaskViewer : WebPart { protected override void CreateChildControls() { base.CreateChildControls(); string hostTag "; // Put the Object Tag the control collection LiteralControl slObj = new LiteralControl(hostTag); Controls.Add(slObj); }
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Hosting in SharePoint (2) Browser Cache a Problem ▫ SPUtility.MakeBrowserCacheSafeLayoutsUrl() Can help but must be in a template to work
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Hosting in SharePoint (3) WebPart Can Create HTML Code ▫ Can Use Silverlight control and ScriptManager ▫ But why?
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Showing Silverlight in WebPart
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Using SharePoint Web Services Creating ServiceReferences to SP “Just Works” ▫ /_vti_bin/Lists.asmx ▫ /_vti_bin/Alerts.asmx ▫ Etc.
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Using SharePoint Web Services (2) Data Returned is Typically XML ▫ Must Use Projection to Shape for DataBinding XElement tasks = e.Results; var qry = from i in e.Result.Descendants(rowName) select new Task() { Title = i.Attribute("ows_Title").Value, Priority = i.Attribute("ows_Priority").Value, Status = i.Attribute("ows_Status").Value, }; theList.ItemsSource = qry.ToList();
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Consume a Web Service
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Debug Considerations Pain Points with Debugging the Silverlight Code ▫ Browser Cache Need Invalidated to Debug ▫ “Run with Debugging” Only Works Locally Remote Debugging Silverlight is not trivial Attach To Process Works Well ▫ Cross Domain May Be An Issue Too.
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Debugging Silverlight in WebPart
Copyright 2009 Wildermuth Consulting Services, LLC Silverlight in SharePoint WebParts – Atlanta SQL Saturday 2009 Questions? Links: ▫ My Blog (Code is Available Here) ▫ My ▫ Silverlight.NET Shawn Wildermuth AgiliTrain Microsoft MVP (C#), MCSD