Well its possible.  I’ve knocked up an example. I took the video library example from silverlight sdk 1.0 and converted it into a sharepoint webpart.

This was relatively simple, I say simple provided you know how to code sharepoint webparts.

 

The conversion process involved

  1. I relocated the assets/xaml/js into the root of the project (this might not be necessary but for speed its easier in webparts to have them in the root, I will investigate packaging directories later).
  2. Edited the Manifest file.  Every deployable content asset like the .js/.jpg/.xaml needs to be listed on the manifest, else it don’t get deployed via stsadm.
  3. Changed the build action on the .xaml files to content.
  4. Rendered with a textwriter parts of the default.html page.  (I should have done a RegisterClientScriptBlock here for the .JS files).
  5. Altered all the paths so that the “this.ClassResourcePath” was the prefix to the path.
  6. All the .js files any paths I placed the fixed location of my “this.ClassResourcePath” infront of the path.  Now if I were to do this properly then all of these paths would be programmatically generated so that I could use the “this.ClassResourcePath” instead.

And that was it.

This whole thing could be customised by using web part properties and tying those into the  SilverlightControlHost creation.

Some initial problems I had was the canvas would not stretch to fit the web part I had to fix its size, this is probably down to me not silverlight though.

Now this has some great usages that I can think of, specifically in the region of data visualisation.  When there are some silverlight controls published and I’m thinking specifically of graphing, (saves me writing them!!!) then we can have some great dashboard type displays.

Add to this the AJAX stlye things I was playing with in sharepoint with a great UI we have some endless possibilties here.

I have got a book on WPF coming so when I’ve got to grips with XAML I hope to create some silverlight that will integrate from sharepoint, using httphandlers to proxy the SAP webservices.  That will be slick.

 Update: I modified the code to pull its sources from a Sharepoint list. The trick here was to edit main.js and remove the section that adds the resources and call a JS function AddVideos() instead.  This function and the VideoLibrary declaration is generated in the RegisterScriptBlock of PreRender.  From there its a simple case of pulling the urls and text from a Sharepoint list, which is a different post entirely.

Here is an updated version, where I broke the xaml trying to make it less oppressive, pointing at the list which hosts two videos.

 

 

 

 

 

Advertisements