Home 
 Downloads 
 Community 
 Documentation 
 Support 
 About 
White Papers: What Is XAML?

What Is XAML?

XAML is Longhorn's Xml Application Markup Language (not to be confused with the "Transaction Authority Markup Language").  The concept of using markup to describe the user interface certainly isn't new.  The XUL people have been doing it for years.  Of course, now that Microsoft is jumping on the bandwagon, there's a lot of ooh-ing and aah-ing and a lot of moaning too.  If you read some of the articles on the Microsoft website that start off with "why is this better?", you'll quickly discover that even Microsoft is having a hard time saying why it's better.  But I digress.

XAML is a markup syntax that describes the user interface.  But it's actually a lot more.  It's a generic class instantiator.  You can use XAML to instantiate classes (create an object that is an instance of a class), assign values to the properties that the class exposes, and wire up events to your application code.  So, it actually does a lot more than just create a UI.  XAML also allows you to define code in-line with the markup.

Will I Be Editing XML Now?

No, of course not, unless you want to (I'm one of those sick people that likes to).  The whole markup will be hidden behind a designer so most people won't even know it's there.

So Why Use It?

Because Microsoft is designing a "standard" (we've heard that before) syntax for describing user interface controls.  The next Visual Studio will serialize your GUI's out to XAML.  Now you can have a deserialization engine (a parser) that can reconstruct the GUI in anything--a Window's client, a web page, a mobile device, and so on.

There are some other interesting advantages as well with the idea of generating the user interface at runtime (if you want to take the performance hit):

  • you can change the UI at runtime
  • you can write a simple designer that let's your customer change the UI to within reason
  • it's easy to implement styles and customize those styles
  • it makes re-use a breeze--just copy&paste the markup
  • it provides a nice clean separation between the user interface itself and the presentation layer
  • it's easy to extend your UI with features such as vector graphics, SVG, and even non-UI things like state machines

About The Presentation Layer

I hope I'm not mincing words here.  If I were to define the UI as the "surface" on which controls are drawn (like buttons and comboboxes, etc), then the typical PL definition is the thing that manages the UI and the interface between the PL and the business layer.  Managing the UI means handling events, doing type conversion, etc.  A lot of times the PL is "polluted" with UI code--just look at what the Visual Studio designer emits--you have UI code generation mixed in with PL event handling.  And even worse, the designer let's you mix in DataSet, DataTable, DataView, SqlConnection, and other non-UI components, creating a snarling mess of UI, PL, and business logic.

So, XAML is a good thing, because it separates out the UI from the PL, and let's the PL do it's job better.

How Does It Work?

All the XAML parsers essentially work the same at the core:

  • 1 & 2 : they use a special namespace mapping construct to map from the assembly namespace to the XML namespace
  • 3: they use the XML prefixes to figure out the namespace in which the class resides, so it can be instantiated
  • 4 & 5: they use XML attributes to assign values to the properties of the class or it's base classes
  • 5: they use a type converter to help convert from the XML string to the type that the property expects (leveraging on several type converters built into .NET)
  • 6: they wire up events to class instance

That, in a nutshell, is it!

Conclusion

XAML isn't the right solution for everyone, but it does address a need for a lot of people.  As tools become more available, it should develop into a very flexible plug-in architecture and offer a variety of features that will be of use to many people.  Even if you don't need runtime modifications or re-use, XAML represents the possibility of a cross-platform and cross-OS standard for generating GUI's.  We've heard that before though, haven't we?

©2004 - 2008 MyXaml.
All Rights Reserved.

 Designed By: IronSuit Software ©2004 - 2008 MyXaml. All Rights Reserved.