Building applications with Silverlight and SharePoint

Presented By: Mike Ammerlaan, Program Manager, Microsoft

I'm really looking forward to this presentation, I think Silverlight is an awesome match with SharePoint and can provide a MUCH better experience.

Oooh, he's showing little facts about SharePoint 2010, there's a new Picture Slideshow webpart out of the box.

He's saying that Silverlight is more about the future-future, not exactly what I wanted to hear to start out. He's going over the history of dynamic web pages starting with DHTML and how Google Maps started the big push to make interactive applications.

His background is that he's a program manager at Microsoft by day, and a programmer of web sites and other code at night for fun. He says that the Silverlight technology really lowers the level of effort required to build an interactive web application.


  • Silverlight in a Nutshell
  • Hosting Silverlight in SharePoint


  • Communicating with SharePoint
    • Client OM, REST, Web Services
  • Tips and Tricks


  • Web Parts
  • Applications
  • Out of Browser

About Silverlight, it's a browser plug-in client, supports Windows, Mac, Linux. Major browsers IE, Firefox, Safari with support for rich media. Subset of .net, subset of WPF, now it includes 100+ controls out of the box compared to when it first came out. Support for Themeable controls now.

XAML is about serialization of .net objects, represents visual UI, separate from the implementation. Expression Blend is the tool that you use to design the Graphical portion.

The graphic design and the coding behind the UI is separated, so a graphic designer and a coder can work on the same application at the same time.

Three types of controls

  • Control
  • UserControl
  • ItemsControl

Four common layouts

  • Grid
  • StackPanel
  • WrapPanel
  • Canvas

One other common class called 'Border'.

Subset of .net types, major missing types are XmlDocument, ADO.NET Data, and ArrayList. There are other ways to implement this type of functionality, these were left out to reduce the footprint of Silverlight.

Includes Web-style networking, calls just inside the same web domain. This is the reason you want to first of all get your Silverlight application on SharePoint so it can leverage the SharePoint OM. You can access other Domains, but there are security considerations to keep in mind.

He's showing a simple Flash Card application implemented in Silverlight, it's stand alone and not tied in to SharePoint.

App.xaml is like Main() in a C# application.

Then he has his application XAML file that contains the GUI and code for his application. He's talking about using a control out of the Silverlight ToolKit which provides for some nifty animation. Sounds like that's a must have for Silverlight J

He's going to take this application and push it up to SharePoint. Wonder what happened to starting with it in SharePoint before you start coding?

Why to user Silverlight?

  • Easier to build - .net, less browser compatibility headaches

More powerful

  • Animations, Media, and .Net

Client Integration

  • Out of Browser
  • File System
  • Multi-Touch

When would you not want to use Silverlight?

  • A Public facing site, does the audience have Silverlight, and is it possible for them to install it?
  • Content heavy web sites. Help site as an example. Copy and Paste is not something that is provided out of the box so a user wouldn't be able to copy things off the site. Of course that could be an advantage in some cases as well.

He says that Silverlight is a good backend for Silverlight since it provides quite a few of the things that Silverlight doesn't have, data access, security etc.

Options for hosting Silverlight

  • Script/Markup
  • Silverlight control
  • Web parts
  • Full page

Setting up the environment

Looks like the best thing to do is just use Visual Studio 2010, it has two different projects that provide for easy deployment, a Silverlight Project, and a SharePoint package.

He's modifying his application now. What he does is change the output of the application and copies it to the MasterPage gallery. He says this is good for getting started, as you get larger you'll want to upload it to its own list.

He's created a custom web part page and inserts the Silverlight web part, then provides the URL to the XAP package that was uploaded to MasterPage. He's using a token that I've seen some other people use in VS2010, it's called ~site. It's nice to be able to not hard code the site in your project.

Once he's done that, his application is running right on the page.

Next step is setting it up for debugging. Silverlight will automatically create a test page for the application on the hard drive. You can go in and create your own test page by adding a HTM file to the project. It must be in your project, you can't reference it unless it's in the project. Then he adds an IFrame to host the project on the page, basically copying the code from the default test page.

Now he can debug his application on the new test web page.

Now he's demonstrating how to deploy it to SharePoint.

He's creating an empty SharePoint project, gives it a name and creates it. Now you add a module which is how you deploy files to your SharePoint site. He removes the sample file, and then adds the Silverlight application by using the 'Project Output References' property on the project. Then he updates the Element.xml to tell what file needs to be copied where in SharePoint.

Now how can you use Silverlight to talk to SharePoint.

  • Web Services – More coverage
  • Client Object Model – Site, Nav, Security Services, very flexible
  • REST – Easiest to use, for fixed list schema that doesn't change
  • Rendering data to the page – Does require code on the site/server


Works only with list data

You must add a reference to ADO.NET 1.5 CTP 2 DLL because it's not there by default in Visual Studio.

Client Object Model

  • To read data from objects, you must ask for it, you have to perform a fetch, then you can read
  • Everything is all asynchronous batch processes, you must call ExecuteAsynch
  • DLL's are in SharepointRoot\14\Template\Layouts\ClientBin

SOAP Web Services

  • Can be used today with 2007
  • Fixed functions exposed, or you can add your own.

He's doing some demos, kind of funny he's adding an announcement to a list, but has to hit F5 to see his changes J

Using REST seems very nice, strong typing, although you do have to process things async so it requires callbacks.

Using the Client Object Model the base thing you use is the ClientContext object, this is what you use to access SharePoint with. Once again it requires async calls to retrieve data. Updating the user interface after the data is returned again requires an async call back to the user interface thread, because it's the only one that can update the user interface.

Fiddler is the recommended tool to debug with Silverlight.

This is the first demo that had problems with it not running. He did say that there are still some bugs in Visual Studio beta 2. I have a feeling it's going to be LATE 2010 before we get Visual Studio based on the performance issues with Beta 1 and the bugs and other work arounds with having to add references to the data CTP's etc.

Xlink he says is the way things are going for reading and writing XML. I haven't heard of this yet, so there's something else to do some follow up on J

I just noticed that when he's doing his code demos, he's not using Snippets like everyone else has been. He has a file up in Notepad that he's copying from. Kind of highlights that this is something he does in his spare time, and not full time.

Looks like all his variables are named in natural English, no camel casing or anything.

I wonder why they didn't have someone who does Silverlight fulltime do this presentation?

Tips, Tricks, and Gotchas


  • Asynchrony and the user interface thread, UI can only be updated by it's own thread
  • Windowless mode vs not, changes accessibility features, windowed mode provides more functionality but clipping of the Silverlight controls. Windowless mode gives you a better UI experience
  • Rich Text/HTML support is tricky within Silverlight. There is not control to edit Rich Text, there are third party controls.


  • Consider your download and application sizes. 1 MB is a good limit to keep, if it hits that you should look at splitting it up. There's also new functionality that will allow you to control the download of Ajax controls, I wonder if it will work with Silverlight.
  • You can make it run in WPF, but there are some minor quirks when you do.
  • Fiddler is very important as a debugging tool.

Now he's showing some other more complex demos

He's shown how to have gauges on a site.

He's extended a Blog to include a Map that can be inserted into a blog post, using the Microsoft Virtual Earth control.

Hmmm, he just mentioned that some of his code is calling internal methods, but that it will be cleaned up when Beta 2 is available. But I thought Ballmer had announced that VS 2010 Beta 2 was available yesterday??? EEEP, just went to MSDN, and they've gone live with the new layout. Not sure if I like it yet. Yup, just checked and Beta 2 is available now, so he'll have to hustle to change his code before it gets posted for this session. Hmmm, ok, maybe he's talking about SharePoint 2010 beta 2???

He's showing a Silverlight grid, and a bunch of controls that are available in Silverlight, the ubiquitous calendar control of course.

Ironic, his demos usually require F5 for the data to be refreshed, kind of defeats one of the big advantages of Silverlight I thought.

Last demo, showing pop ups on his original flash card application. In full screen for Silverlight you can only use the mouse and the cursor keys to prevent phishing attacks.

This demo was ok, was hoping for more about integration with SharePoint, it was more about Silverlight shiny things than how to leverage Silverlight in SharePoint.

Off to the next presentation, Building solutions with BCS J