XAML
Encyclopedia
Extensible Application Markup Language (XAML, icon) is a declarative
Declarative programming
In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow. Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish, rather than...

 XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

-based language created by Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 used for initializing structured values and objects. It is available under Microsoft's Open Specification Promise. The acronym originally stood for Extensible Avalon Markup Language - Avalon being the code-name for Windows Presentation Foundation
Windows Presentation Foundation
Developed by Microsoft, the Windows Presentation Foundation is a computer-software graphical subsystem for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0. Rather than relying on the older GDI...

 (WPF).

Overview

XAML is used extensively in .NET Framework 3.0 & .NET Framework 4.0 technologies, particularly Windows Presentation Foundation (WPF)
Windows Presentation Foundation
Developed by Microsoft, the Windows Presentation Foundation is a computer-software graphical subsystem for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0. Rather than relying on the older GDI...

, Silverlight, and Windows Workflow Foundation (WF)
Windows Workflow Foundation
Windows Workflow Foundation is a Microsoft technology that provides an API, an in-process workflow engine, and a rehostable designer to implement long-running processes as workflows within .NET applications...

. In WPF, XAML forms a user interface markup language
User interface markup language
A user interface markup language is a markup language that renders and describes graphical user interfaces and controls. Many of these markup languages are dialects of XML and are dependent upon a pre-existing scripting language engine, usually a JavaScript engine, for rendering of controls and...

 to define UI elements, data binding, eventing, and other features. In WF, workflow
Workflow
A workflow consists of a sequence of connected steps. It is a depiction of a sequence of operations, declared as work of a person, a group of persons, an organization of staff, or one or more simple or complex mechanisms. Workflow may be seen as any abstraction of real work...

s can be defined using XAML.

XAML elements map directly to Common Language Runtime
Common Language Runtime
The Common Language Runtime is the virtual machine component of Microsoft's .NET framework and is responsible for managing the execution of .NET programs. In a process known as just-in-time compilation, the CLR compiles the intermediate language code known as CIL into the machine instructions...

 object instances, while XAML attributes map to Common Language Runtime properties and events on those objects. XAML files can be created and edited with visual design tools like Microsoft Expression Blend, Microsoft Visual Studio
Microsoft Visual Studio
Microsoft Visual Studio is an integrated development environment from Microsoft. It is used to develop console and graphical user interface applications along with Windows Forms applications, web sites, web applications, and web services in both native code together with managed code for all...

, and the hostable Windows Workflow Foundation visual designer. They can also be created and edited with a standard text editor
Text editor
A text editor is a type of program used for editing plain text files.Text editors are often provided with operating systems or software development packages, and can be used to change configuration files and programming language source code....

, a code editor like XAMLPad
XAMLPad
XAMLPad is a lightweight tool originally provided with the .NET Framework 3.0 SDK to quickly create simple Extensible Application Markup Language files...

, or a graphical editor like Vector Architect.

Anything that is created or implemented in XAML can be expressed using a more traditional .NET language, such as C# or Visual Basic.NET. However, a key aspect of the technology is the reduced complexity needed for tools to process XAML, because it is based on XML. Consequently, a variety of products are emerging, particularly in the WPF space, which create XAML-based applications. As XAML is simply based on XML, developers and designers are able to share and edit content freely amongst themselves without requiring compilation. Since it is strongly linked to the .NET Framework 3.0 technologies, the only fully compliant implementation at present is Microsoft's .

Technology

A XAML file can be compiled into a .BAML file (Binary Application Markup Language
Binary Application Markup Language
The Binary Application Markup Language is a file format of Microsoft that is generated by compiling XAML files.-Generation:A XAML file can be compiled into a Binary Application Markup Language file having the .BAML extension.), which may be inserted as a resource into a .NET Framework assembly...

), which may be inserted as a resource into a .NET Framework assembly. At run-time, the framework engine extracts the .BAML file from assembly resources, parses it, and creates a corresponding WPF visual tree or workflow.

When used in Windows Presentation Foundation, XAML is used to describe visual user interface
User interface
The user interface, in the industrial design field of human–machine interaction, is the space where interaction between humans and machines occurs. The goal of interaction between a human and a machine at the user interface is effective operation and control of the machine, and feedback from the...

s. WPF allows for the definition of both 2D and 3D objects, rotations, animations, and a variety of other effects and features.

When used in Windows Workflow Foundation contexts, XAML is used to describe potentially long-running declarative logic, such as those created by process modeling tools and rules systems. The serialization
Serialization
In computer science, in the context of data storage and transmission, serialization is the process of converting a data structure or object state into a format that can be stored and "resurrected" later in the same or another computer environment...

 format for workflows was previously called XOML, to differentiate it from UI markup use of XAML, but now they are no longer distinguished. However, the file extension for files containing the workflow markup is still "XOML".

Templates

XAML uses a specific way to define look and feel
Look and feel
In software design, look and feel is a term used in respect of a graphical user interface and comprises aspects of its design, including elements such as colors, shapes, layout, and typefaces , as well as the behavior of dynamic elements such as buttons, boxes, and menus...

 called Templates, differing from Cascading Style Sheet syntax; it is closer to XBL
XBL
XBL is an XML-based markup language used to declare the behavior and look of XUL-widgets and XML elements.XBL was developed by the Mozilla project for use in the Mozilla Application Suite; the language is not currently described by any formal standard and is thus proprietary to Mozilla, with the...

.

Example

This Windows Presentation Foundation example shows the text "Hello World!" in the top-level XAML container called Canvas.


xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Hello World!



The schema (the xmlns="http://schemas.microsoft.com..." part) may have to be changed to work on your computer.
Using a schema that Microsoft recommends, the example can also be


Hello World!



This can be integrated into a Web page
Web page
A web page or webpage is a document or information resource that is suitable for the World Wide Web and can be accessed through a web browser and displayed on a monitor or mobile device. This information is usually in HTML or XHTML format, and may provide navigation to other web pages via hypertext...

 if WPF is installed using XBAPs (XAML Browser Applications) that are compiled applications running in a sandboxed environment hosted within the browser. Another way is to use the Silverlight plugin
Microsoft Silverlight
Microsoft Silverlight is an application framework for writing and running rich Internet applications, with features and purposes similar to those of Adobe Flash. The run-time environment for Silverlight is available as a plug-in for web browsers running under Microsoft Windows and Mac OS X...

. The code cannot be included directly in an HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

 page; rather it must be loaded into the page via JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

. If .NET 3.0 or later is installed, loose XAML files can also be viewed on their own in a compatible Web browser
Web browser
A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier and may be a web page, image, video, or other piece of content...

 (including Internet Explorer
Internet Explorer
Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...

 and Firefox) in conjunction with the .NET Framework 3.0, without the need for the Silverlight plugin. Loose XAML files are markup-only files limited to defining the visual content to be rendered. They are not compiled with an application.




XAML Example




The MySilverlight.js file must contain the code that loads the above XAML code (as an XML file) under the MySilverlight html element.

Differences between versions of XAML

There are three Microsoft main implementation of XAML:
  • The Windows Presentation Foundation
    Windows Presentation Foundation
    Developed by Microsoft, the Windows Presentation Foundation is a computer-software graphical subsystem for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0. Rather than relying on the older GDI...

     version, which is used for the .NET Framework
    .NET Framework
    The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

     beginning with .NET Framework 3.0
  • The Silverlight 3 version
  • The Silverlight 4 version


These versions have some differences in the parsing behavior.

Additionally, the XAML parsing between Silverlight 3 and Silverlight 4 is not backward compatible
Backward compatibility
In the context of telecommunications and computing, a device or technology is said to be backward or downward compatible if it can work with input generated by an older device...

. XAML files which are accepted by Silverlight 3 may not be accepted or parsed differently in Silverlight 4.

Criticism

The European Committee for Interoperable Systems
European Committee for Interoperable Systems
The European Committee for Interoperable Systems is an international non-profit association founded in 1989 in order to promote interoperability and market conditions in the Information and Communications Technology sector allowing vigorous competition on the merits and a diversity of consumer...

 argues that Microsoft's use of XAML in its Silverlight product aims to introduce content on the World Wide Web that can only be accessed from the Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 platform.

However, using a plugin, XAML is viewable in some non-Microsoft browsers on Windows and Mac
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, and Microsoft provides direct support for Novell
Novell
Novell, Inc. is a multinational software and services company. It is a wholly owned subsidiary of The Attachmate Group. It specializes in network operating systems, such as Novell NetWare; systems management solutions, such as Novell ZENworks; and collaboration solutions, such as Novell Groupwise...

's development of a Silverlight viewer for GNU
GNU
GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...

/Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 called Moonlight
Moonlight (runtime)
Moonlight is a free and open source implementation of Microsoft's Silverlight for Linux and other Unix based operating systems, developed by the Mono Project...

. As of January 2010, Moonlight 2 is a compatible implementation of Silverlight 2.

See also

  • Comparison of user interface markup languages
    Comparison of user interface markup languages
    The following tables compare general and technical information for a number of user interface markup languages. Please see the individual markup languages' articles for further information...

  • EMML
    EMML
    EMML, or Enterprise Mashup Markup Language, is an XML markup language for creating enterprise mashups, which are software applications that consume and mash data from variety of sources, often performing logical or mathematical operations as well as presenting data. Mashed data produced by...

  • JavaFX
    JavaFX
    JavaFX is a software platform for creating and delivering rich Internet applications that can run across a wide variety of connected devices....

  • Layout manager
    Layout manager
    Layout managers are software components used in widget toolkits which have the ability to lay out widgets by their relative positions without using distance units. It is often more natural to define component layouts in this manner than to define their position in pixels or common distance units,...

  • List of user interface markup languages
  • NextStep/Cocoa Interface Builder
    Interface Builder
    Interface Builder is a software development application for Apple's Mac OS X operating system. It is part of Xcode , the Apple Developer Connection developer's toolset. Interface Builder allows Cocoa and Carbon developers to create interfaces for applications using a graphical user...

  • Open XML Paper Specification
  • ZUML

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK