Posts Tagged ‘Silverlight’

XAML, Microsoft Silverlight 2.0 and WPF

Sunday, March 22nd, 2009

Whenever new technology comes about, there is an automatic reluctance to spend time looking into it.  I think this is probably quite a sensible thing, since you can’t possibly keep up with everything going on at once.  When Silverlight came out, I had a brief look at it and thought “oh, it looks like Microsoft are trying to compete with Flash.”  I thought it wasn’t really worth worrying about at the time, as Adobe have pretty much got the market cornered as far as browser animation plugins go, and I didn’t think people would really want to bother installing another one.

More recently, I’ve had a bit more of a look at Silverlight, and I’m wondering whether to invest some time learning it.  It does seem to be getting a bit more popular.  One of the things that I’ve heard (I don’t know whether this is true), is that Silverlight will work off the same XAML documents as WPF, which means that you can create a single XAML file and use it as an interface for both web and Windows.  

Granted, I don’t actually use WPF yet either – from what I’ve heard of that, it still needs some work before it is a full replacement for Windows Forms, and I have heard that it can cause speed issues.  On the other hand, the idea of being able to create a single user interface which can be used for both web and windows is very appealing.

Let me step back for a minute and explain.  XAML (Extensible Application Markup Language) is Microsoft’s XML based language which is used for defining user interface.  I think they invented it for WPF (Windows Presentation Foundation), which is supposed to eventually replace Windows Forms.  The idea is that you can define a user interface in an XML document (much as you do in HTML), and then it gets rendered.

You may ask “why not just use HTML?”  The answer is that while HTML has plenty of extensions which allow you to manipulate the DOM (document object model) via AJAX (asynchronous Javascript and XML) or similar, it is messy.  XAML, on the other hand, is designed to be a user interface for applications, whereas HTML was just designed for static pages.  This means that you don’t need to spend so much time mucking about with code to manipulate the DOM when you want to make changes to a page.  Of course, AJAX frameworks will do a lot of that for you, but there are usually some complications at some point along the way, especially when things go wrong.

One of the big issues of course is browser compatibility.  Apparently (according to Wikipedia), XAML can be rendered in some browsers (Internet Explorer and Firefox at least) with no plugin, as long as .NET 3.0 is installed on the PC with the browser in.  For other browsers, the Silverlight plugin is available to deal with the XAML.  On non-Windows platforms, Microsoft have released a plugin called Moonlight to deal with it.  

I’d be interested to have comments from what other people’s experiences of Silverlight, XAML and WPF have been like and whether you’d like me to post more about any or all of these subjects.