.NET 3.5: Introduction to XAML – Part 1

What is XAML

So what is XAML anyways?  It stands for eXtensible Application Markup Language and is based on XML.  It was initially created to be used in WPF (Windows Presentation Foundation) but is now being used also in WF (Windows Workflow Foundation), Silverlight, and XPS (XML Paper Specification). 


So why another markup language?  The reason behind creating this to be used in WPF is to allow the designers (those responsible for the graphical user interface) and developers (those who code the behavior)  to collaborate well, to have them work on their stuff separately, and once done merge their stuff without a hitch.  End result is a top notched graphical user interface and a perfectly working application.


XAML Tools

The major tools for creating XAML are: Expression Design, Expression Blend, and Visual Studio (starting from version 2008).  As a developer, you can actually just use Visual Studio to create your visual elements in XAML and code-behind it.  But for more complex graphics, the two Expression products are more suitable.



Since XAML is a declarative language, it is used to describe objects in .NET, just like what HTML is used to describe what should be displayed on a Web page.  XAML describes objects form a subset of .NET namespaces, which include System.Windows, System.Windows.Controls, System.Windows.Data, and System.Windows.Media

Since XAML is XML based, it can be used to represent a tree of objects.  And as with all XML markups, XAML is case sensitive.

XAML in WPF uses WPF namespace (the same namespace concept used in XML) to avoid confusion with XAML used in WF, and so on.

XAML is compiled, at runtime, into BAML (Binary Application Markup Language), a more optimized form for parsing, and embedded as a resource in EXE or DLL.

A sample XAML listed below describes a button object.  It will display a Button control on a StackPanel layout on the UI with default visual presentation and default behaviors.

  <Button Content="Click Me"/>

Other sample XAMLs:

<Button Background="Blue" Foreground="Red" Content="This is a button"/>
    <SolidColorBrush Color="Blue"/>
    <SolidColorBrush Color="Red"/>
    This is a button

If you are coming form an ASP.NET or Web background, these XAML samples do look familiar.  Stylesheets is what comes into my mind though.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s