Just a bit of fun really but I was pondering over breakfast what the absolute smallest Silverlight “app” is that you can build?
I made a vanilla web site project in Visual Studio and stared at the object tag instantiating the plug-in;
<form id="form1" runat="server" style="height:100%"> <div id="silverlightControlHost"> <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/SmallApp.xap"/> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="4.0.50826.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/> </a> </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div> </form>
I figured that most of this could quite happily be discarded without too much damage and I added a splash screen;
<form id="form1" runat="server" style="height: 100%"> <div id="silverlightControlHost"> <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/SmallApp.xap" /> <param name="splashScreenSource" value="ClientBin/splash.xaml" /> </object> </div> </form>
The form and the div could go as well. I was secretly hoping that I could leave out the source parameter and have the app purely displaying the contents from the splash screen which looks like;
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <TextBlock Text="Hello, I'm Silverlight" FontSize="36"/> </Canvas>
but if I omit the source then I find that nothing gets displayed so I guess I have to at least point at a XAP file. Could it be an empty XAP file?
And then I remembered. There was a time before XAP files when Silverlight apps were just loose XAML files and (Silverlight being backwardly compatible) that should still work. So maybe I could forget the XAP and go with;
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/splash.xaml" /> </object>
So, here it is below with a shiny blue background. Hopefully it doesn’t take too long to load…