Create Silverlight Apps with Notepad

Did you know that you can write simple Silverlight applications using just a text editor without using an IDE or compiler?
Although it is recommended to use silverlight.js to start your silverlight application in a robust way, you don’t even need that. Just create a html file with a text editor of your choice and embed the XAML code.

The absolute minimum is this:



	       
	    

This is a plain html file. The Silverlight plugin is hosted using the object tag. The XAML content is not stored in a xap file, but in a local script of type text/xaml. Inside this script block any XAML can be placed.
The script can also use embedded storyboards to automatically triggers animations.
A more complex example which creates a rotating rectangle with text and a logo is shown here:





	       
	    

The script comprises of the visual elements Border, Grid, TextBlock and Image and four Storyboards which control the animation.
Inline XAML can be used to create nice looking splashscreens or single file demos.
Try it. Just copy the file above to a html file and open it. Provided that you have the Silverlight plugin installed you can see the animation.

Screenshots:

Live demo

If you want to let Silverlight interact with Javacript, just add another script block at the top of the page:


In order to call it, add the event handler to the Grid in XAML like this:

<Grid x:Name="Frame" Background="SteelBlue" Cursor="Hand" MouseLeftButtonDown="nav"> 
...

That’s it!

Leave a Reply

Your email address will not be published. Required fields are marked *