Silverlight, SharePoint and ARF

Search

Accessible SharePoint WebSites
Download ARF

Silverlight, SharePoint and ARF

http://blog.thekid.me.uk

At a recent SharePoint architects meeting at Microsoft, Tony & Tony from Acentium demonstrated some Silverlight integration with SharePoint. This inspired me to see how easy it would be to use Silverlight with the ARF framework.

Silverlight & XAML

Silverlight uses Xaml to produce the UI and XAML is just XML markup. Using XAML you can create a variety of effects, animations and layouts which can make your website more dynamic.

Silverlight is just an <object> tag in the page and so is really another HTML tag, just like any other. This can easily be added to the SharePoint page, either in the page layout or dynamically by another control.

<object data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="48">
    <param name="source" value="/_layouts/ARF/ARF.Silverlight.App.xap">
    <param name="onerror" value="onSilverlightError">
    <param name="background" value="white">
    <param name="minRuntimeVersion" value="2.0.31005.0">
    <param name="autoUpgrade" value="true">
    <param name="initParams" value="xamlContainerID=idMenu">
    <a href="
http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
        <img src="
http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none">
    </a>
</object>
<iframe style="visibility:hidden;height:0;width:0;border:0px"> </iframe>

As the ARF framework is based around XML and XSLT it sounded like it fit in very well with Silverlight and XAML.

ARF and XAML

ARF uses XSLT to produce the HTML and so there is no reason why it cannot XAML instead of HTML. By changing the XSLT used by the ARF controls to produce XAML its possible to output the XAML directly in the page. Once its in the page we can get the Silverlight control to dynamically load the XAML and display the results.

In order to achieve this I have added a new control to the ARF deployment. This control is packaged in to a XAP file and deployed to the _layouts folder. This can then be loaded when displaying Silverlight control using ARF. This control can then be rendered by the XSLT along with the XAML which will produce the UI.

Below is an example of a dynamic Silver light menu control.

<param name="initParams" value="xamlContainerID=idMenu"/>
....
<xml id="idMenu" style="display:none">
   <xsl:apply-templates select="Items"/>
</xml>

Here we are passing parameters to the Silverlight control, telling it the ID of the control on the page which contains the XAML. The ARF Silverlight control will look for this ID, load the XAML and display the UI. It will also hookup event handling for any Buttons found in the XAML, allowing them to navigate to the supplied URL.

How it works in ARF

By way of a demonstration I have added some Silverlight navigation to the SPWorks website.

image

The links allow you to turn Silverlight on or off. This is done by using one of the ARF features, the PathManager control.

image The PathManager is a special control in ARF as it does not generate and UI or XML, it is just there to modify the path of the XSLT. This allows you to create your layouts using XSL found in the 'XSL Library', but then later modify where the XSL is actually loaded from dynamically at runtime.

In the case of the SPWorks website we are using a cookie to store if Silverlight is on or not. The cookie is then used to load the XSL from a different location. The image shows the XSL for Silverlight is contained in a sub-folder of the main 'XSL Library'.

Using this technique you can easily change the way your site is rendered, just by providing different XSL for the different situations.

The PathManager is fully extendable and so you can provide your own implementation. This way you can switch XSL locations dependant on your own criteria, possibly for different browsers or languages.

To see how the XAML is produced you can download the XSL for the SPWorks navigation.

Also, just for completeness, this could have been achieved another way with ARF. It is possible to get ARF to switch the master page used based upon a cookie value. I could have done this and modified the XSL location directly on the controls in the new master page. In this situation that didn't seem to be the best solution, but it would have worked just as well.

ARF and its releases

A new release of ARF is available for download containing this new Silverlight control and XAP file. Feel free to use in your own projects as the Silverlight control is not dependant on the ARF framework.

Just a note about the ARF releases. ARF is released as and when new functionality or fixes are added. This way we hope to be able to respond to bugs and feature requests quickly. For each release there will be a WSP and the corresponding source. We recommend that you only use the latest version when starting a new project, when it contains a bug fix that you need or there is new functionality which will help your project.

Posted by Vincent Rothwell on Tuesday, 28 Oct 2008 14:55  - 15 Comments
Orininally printed from http://thekid.me.uk - Copyright Vincent Rothwell 2007
 

Comments

Tuesday, 28 Oct 2008 02:38 by bazztrap
I like what you are doing .. I have installed this yet... but planing to do so this weekend anyway there is bug with silver light nav bar in firefox Unhandled Error in Silverlight 2 Application [Arg_NullReferenceException] Arguments: Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.31005.0&File=mscorlib.dll&Key=Arg_NullReferenceException at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers, Boolean expandTemplatesDuringParse) at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers) at System.Windows.Markup.XamlReader.Load(String xaml) at ARF.Silverlight.App.XamlRender..ctor(IDictionary`2 p) at ARF.Silverlight.App.App.Application_Startup(Object sender, StartupEventArgs e) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

Tuesday, 28 Oct 2008 03:23 by Vince
Thanks, I'll have a look at it. Although it looks like a problem with the Firefox implementation...not passing in the initParams correctly?? --Vince

Tuesday, 28 Oct 2008 04:28 by Vince
OK, fixed it. Turns out that in inconsistency between DOMs hurts you even with Silverlight. I was using innerHTML, which worked fine for IE, but neiher FireFox or Chrome liked it!! Thanks for taking the time to point that out. --Vince

Monday, 24 Nov 2008 04:32 by Oskar Austegard
Ok - that was WAY too subtle of a difference (Silverlight on/off). I had to interrogate the View Source to see what you changed. Can't you make the menus dance or something... ;-)

Wednesday, 26 Nov 2008 04:19 by Vince
Love to, but couldn't be bothered...much more interested in getting it to do it, than what it looks like ;-) --Vince

Wednesday, 20 May 2009 06:58 by Oyun
That's it fixed , thanks..

Wednesday, 24 Jun 2009 04:08 by love_moss_not
meh... silver who?

Wednesday, 26 Aug 2009 01:20 by Diyet listesi
That's it fixed , thank yoku :)

Friday, 30 Oct 2009 03:11 by sikiş
thanks for all admin owe you gratitude..

Sunday, 8 Nov 2009 03:35 by klip izle
Thanks, I'll have a look at it

Monday, 21 Dec 2009 08:18 by araba
hii Admin how are Youı

Wednesday, 28 Apr 2010 04:31 by rfarqleet
Thank you for the good post, I agree with the majority of your points.

Tuesday, 18 May 2010 10:13 by seo danışmanlığı
thank's very good much

Saturday, 19 Jun 2010 12:33 by antep fıstığı
thank's very good much

Monday, 21 Jun 2010 09:57 by Sac ekim
great article my friend



Url

Email

Comments