Added some links regarding Cider, the XAML Visual Designer for VS Orcas (see below under Tools/Microsoft).
In the Nov. 29th newsletter, Chris Maunder mentioned that any XAML and Avalon articles would be welcomed. Based on a CP survey from several months ago, it would seem that at least half of CPians have never heard of XAML or don't know what it is. I thought it might be useful to put together a XAML Resources article, which I'll try to keep up to date as XAML evolves. Like any technology that suddenly discovers itself to be in the sights of Microsoft, there often results considerable emotional reaction. XAML is no exception. There are three primary camps that you will encounter as you follow the various resources below:
- The XAML purists, who feel that Microsoft's XAML is the "only" XAML
- The "Microsoft stole this idea from us" camp
- The "XAML means 'eXtensible Application Markup Language'" relying on XML as the vehicle to represent declarative programming constructs.
The reader should be aware that I fall in the last camp! Nonetheless, I'll try to present the XAML resources from each of these perspectives as unbiased as possible. If anyone feels I've done them a disservice, let me know and I'll endeavor to correct it. Please keep in mind that this article is supposed to present resources. The descriptions of the different vendors is intentionally brief and is not intended to be an advertisement or endorsement for any particular vendor.
What Is XAML, Technically Speaking?
The only agreement that appears to exist is how XAML is implemented as a technology. When you try to get a definitive answer for "What Is XAML" from a descriptive point of view, you get a lot of different answers.
Everything you'll see here relies in the idea that XAML is an XML-compliant format to describe an object graph. In most cases:
- XML namespaces are used to map to code namespaces (this is very .NET'ish)
- XML element tags correspond to class names
- XML element attributes correspond to properties of the class
- Object graphs are constructed by exposing collections as properties. A default collection is either implied when a node has children (a class-collection graph) or must be explicitly stated (a class-collection-class graph)
- Various implementations support properties whose type are abstract classes, referencing previously instantiated classes, creating complex bindings, styles, visual trees, etc.
- XAML is a form of declarative programming
You will see several terms used frequently (and already used here).
The simplest definition of declarative programming is that it is the set of instructions defining the application's data and data relationships. Conversely, imperative programming is the set of instructions telling the application how to manipulate that data. A more complex definition can be found on Wikipedia.
An object graph is essentially a tree describing objects, their children, and their initial properties. Consider an application that has a form that has a collection of controls. Each control (like a group box) may have it's own set of controls. The application also has menus, toolbars, statusbars, etc. The application can also create object graphs for database connections, data sets, containers, state machines, messaging and event managers, etc, and of course application specific classes. All of these classes have properties that can be initialized as well. The entire picture of the application's class instance tree and their properties is the object graph.
Serialization is the process of encoding and object graph instance into a format that allows for persistence, is re-usable, is often transportable, and captures all the relevant meaning of the original object graph. XAML is a serialization format with the potential for making cross-platform UI definition possible regardless of platform and language. Consider the Visual Studio designer. It "serializes" .NET forms into either C# or VB. Not only does this introduce a language dependency but it also introduces a reliance on the .NET classes.
Deserialization is the process of reconstructing the encoded data into the original object graph instance. Although XAML tag and property names are based on their underlying classes, it's easier to write wrappers that implement these names rather than trying to port .NET to another platform/language. Furthermore, XSLT can be used to translate between tag/property names of one system to another, as demonstrated here.
Why Use XAML?
- XAML allows the programmer to separate the user interface (UI) definition from the underlying business logic.
- XAML, since it is parsed, offers the possibility that a single UI definition can be used on different platforms
- XAML allows the user to edit the presentation layer (not necessarily directly, but with a simple tool) without requiring the usual development tools or programming knowledge
How Is XAML Used?
XAML is used for both web-based and client-based applications. Within those two segments, there are three camps regarding the usage of XAML:
- Declaratively programming 2D and 3D vector graphics (VG)
- Declaratively programming traditional (meaning no VG) UI's and their controls (or widgets)
- As a general declarative programming language for UI and non-UI constructs
Almost everything you will see here focuses on using XAML to describe the user interface.
Who Is Doing XAML?
This section is bound to get lots of criticism, because I'm using the term "XAML" in the broad context of being an XML format for declarative programming.
A word about the word "Avalon". Avalon is more than just 2D/3D vector graphics. In the context of this article, when I say "Avalon namespace" or "Avalon clone" or "partial clone", I'm referring specifically to the VG portion of Avalon that certain vendors have attempted to implement, at least in terms of class and property name compatibility. Nor is Avalon XAML. XAML is the XML language that builds object graphs out of Avalon's classes.
Laszlo is an open source platform for developing web applications using their "rapid XML development" approach. It does not implement the Avalon namespace. While not supporting VG directly, Laszlo provides integration of media and interactivity into web pages using XML in a declarative, text-based development environment. Note that nowhere does Laszlo claim or use the term "XAML". I'm including them here because of their XML/declarative foundations.
Microsoft's XAML has the weight of Avalon's 2D and 3D VG engine and non-VG support for classic .NET controls. Microsoft provides a very rich XAML experience with visual trees, complex bindings, etc. Microsoft's focus so far has been on applying XAML to user interface programming. Microsoft's XAML text editor supports intellisense (VS2005, downloadable here).
Mobiform has implemented a partial clone of the current version of the Avalon namespace. Mobiform supports 2D VG but not non-VG controls. Mobiform has mentioned that it is beginning work on supporting 3D VG. Mobiform's emphasis regarding XAML seems to be primarily on web-based applications but appears to support .NET client applications as well.
MyXaml is an open source parser capable of working with any "XAML-friendly" .NET class, including Avalon, but does not implement a clone of Avalon. MyXaml support non-VG controls. 2D VG is supported using VG.net (a non-Avalon VG engine). MyXaml's emphasis is on XAML as a declarative programming language not restricted to UI's. I could of course write more, but I won't.
Xamlon has implemented a partial clone of the current version of the Avalon namespace. Xamlon supports 2D VG and non-VG controls. Xamlon emphasizes 2D VG. 3D support is very basic apparently.
The XUL community consists primarily of open-source Java-based implementations. There are many players here, and including the XUL community under the aegis of XAML resources is sure to raise the hackles of some purists. However, they fit the generic definition I have chosen to support--XML for declarative programming. Obviously these XUL motors do not implement an Avalon clone nor do they implement VG. Because most of these motors are implemented in Java, they are well suited for web development. Some require Swing, others, like Thinlet, do not.
What Tools Are Available?
Microsoft does not provide any designers but has released a Community Technology Preview (CTP) edition of Avalon usable on WinXP SP2 with the VS2005 beta 1 release.
Microsoft is developing "Cider", the code name for the XAML Visual Designer in VS Orcas. VS Orcas "provides developers with support for building WinFX applications using the final released version of Visual Studio 2005." See here. Richard Bailey, a developer on Cider, also suggests these links:
First Cider CTP
From their website (this seemed an excellent description): "Mobiform has an visual XML Editor (Aurora) that can produce XAML documents..., a Browser (Corona) that can read and render Avalon XAML documents, and .NET user controls for using XAML and Avalon in your .NET Programs." There are also alpha builds of their 3D builder and viewer.
MyXaml has a Visual Studio plug-in and a stand-alone form designer. MyXaml also provides a Lint utility to edit, validate and view the UI. For 2D VG, MyXaml relies on the full featured VG designer from VG.net.
Xamlon has a Visual Studio plug-in and a stand-alone Xaml-Pad editor but no VG designer.
It appears that designer tools are very sparse in the XUL community. However, recently, a GUI editor called ThinG has been written for Thinlet.
The best information on Microsoft's XAML can be found from various bloggers. If I've left you out, my apologies and let me know who you are.
Hopefully this gave you an introduction to the XAML technologies available to you today. Unfortunately, there is no definitive answer to what you should use today. It depends on what your goals are and what your target platform is. It appears though that if you want to use Microsoft's technology in a stable release, you'll have to wait a while. None-the-less, it seems that XAML, and more generally the concept of declarative programming, is going to become a factor that you should at least be aware of. I will be updating this article as feedback and relevant information becomes available.