Extensible Application Markup Language (XAML ) is a
declarative XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
-based language that
Microsoft
Microsoft Corporation is an American multinational corporation, multinational technology company, technology corporation producing Software, computer software, consumer electronics, personal computers, and related services headquartered at th ...
developed for initializing structured values and objects. It is available under Microsoft's
Open Specification Promise.
XAML is used extensively in
Windows Presentation Foundation
Windows Presentation Foundation (WPF) is a free and open-source graphical subsystem (similar to WinForms) originally developed by Microsoft for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was init ...
(WPF),
Silverlight
Microsoft Silverlight is a discontinued application framework designed for writing and running rich web applications, similar to Adobe's runtime, Adobe Flash. A plugin for Silverlight is still available for a very small number of browsers. Wh ...
,
Workflow Foundation
Windows Workflow Foundation (WF) 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. The latest version of WF was re ...
(WF),
Windows UI Library (WinUI) and
Universal Windows Platform
Universal Windows Platform (UWP) is a computing platform created by Microsoft and first introduced in Windows 10. The purpose of this platform is to help develop universal apps that run on Windows 10, Windows 10 Mobile (discontinued), Windows ...
(UWP). In WPF and UWP, XAML is a
user interface markup language to define UI elements, data binding, and events. In WF, however, XAML defines
workflow
A workflow consists of an orchestrated and repeatable pattern of activity, enabled by the systematic organization of resources into processes that transform materials, provide services, or process information. It can be depicted as a sequence ...
s.
XAML elements map directly to
Common Language Runtime (CLR) object instances, while XAML attributes map to CLR properties and events on those objects.
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.
Technology
XAML originally stood for Extensible Avalon Markup Language, ''Avalon'' being the code-name for
Windows Presentation Foundation
Windows Presentation Foundation (WPF) is a free and open-source graphical subsystem (similar to WinForms) originally developed by Microsoft for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was init ...
(WPF).
[Rob Relyea : January 2004 – Posts](_blank)
Before the end .NET Framework 3.0 development, however, Microsoft adopted XAML for
Workflow Foundation
Windows Workflow Foundation (WF) 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. The latest version of WF was re ...
(WF).
In WPF, XAML describes visual
user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine f ...
s. WPF allows for the definition of both 2D and 3D objects, rotations, animations, and a variety of other effects and features. A XAML file can be compiled into a
Binary Application Markup Language (BAML) file,
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.
In WF contexts, XAML describes potentially long-running declarative logic, such as those created by process modeling tools and rules systems. The
serialization
In computing, serialization (or serialisation) is the process of translating a data structure or object state into a format that can be stored (e.g. files in secondary storage devices, data buffers in primary storage devices) or transmitted (e ...
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".
XAML uses a specific way to define
look and feel
In software design, the look and feel of a graphical user interface comprises aspects of its design, including elements such as colors, shapes, layout, and typefaces (the "look"), as well as the behavior of dynamic elements such as buttons, box ...
called ''Template''s; differing from
Cascading Style Sheet syntax, it is closer to
XBL.
To create XAML files, one could use
Microsoft Expression Blend,
Microsoft Visual Studio
Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platfor ...
, the hostable WF visual designer, or XAMLPad.
Example
This Windows Presentation Foundation example shows the text "Hello, world!" in the top-level XAML container called Canvas.
The schema (the part) may have to be changed to work on your computer.
Using a schema that Microsoft recommends, the example can also be
This can be integrated into a
Web page 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. The code cannot be included directly in an
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
page; rather it must be loaded into the page via
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
. If .NET 3.0 or later is installed, loose XAML files can also be viewed on their own in a compatible
Web browser
A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen. Browsers are used on ...
(including
Internet Explorer
Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated IE or MSIE) is a series of graphical user interface, graphical web browsers developed by Microsoft which was used in the Microsoft Wind ...
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.
A crucial part of utilizing XAML to its full potential is making appropriate usage of binding, as well as being comfortable with creating your own custom user elements as required, for your specific needs. Binding can be done as follows:
Differences between versions of XAML
There are three main Microsoft implementations of XAML:
*
Windows Presentation Foundation
Windows Presentation Foundation (WPF) is a free and open-source graphical subsystem (similar to WinForms) originally developed by Microsoft for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was init ...
(WPF), first available with
.NET Framework 3.0
Microsoft started development on the .NET Framework in the late 1990s originally under the name of Next Generation Windows Services (NGWS). By late 2001 the first beta versions of .NET 1.0 were released. The first version of .NET Framework was ...
*
Silverlight
Microsoft Silverlight is a discontinued application framework designed for writing and running rich web applications, similar to Adobe's runtime, Adobe Flash. A plugin for Silverlight is still available for a very small number of browsers. Wh ...
3 and 4, first available for
Internet Explorer 6
Microsoft Internet Explorer 6 (IE6) is a graphical web browser developed by Microsoft for Windows operating systems. Released on August 24, 2001, it is the sixth, and by now discontinued, version of Internet Explorer and the successor to Inter ...
and now deprecated
*
Windows UI Library (formerly UWP XAML and WinRT XAML), first shipped with
Windows 8
Windows 8 is a major release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on August 1, 2012; it was subsequently made available for download via MSDN and TechNet on August 15, 2012, and later to ...
and
Windows Server 2012, but now available as a part of the
Windows App SDK
Windows App SDK (formerly known as Project Reunion) is a software development kit (SDK) from Microsoft that targets the development of Windows API, native desktop applications on Windows 11 and Windows 10 back to version 1809.
Windows App SDK doe ...
These versions have some differences in the parsing behavior. Additionally, the Silverlight 4 XAML parser is not 100%
backward-compatible with Silverlight 3 files. Silverlight 3 XAML files may be rejected or parsed differently by the Silverlight 4 parser.
Response from the competition
In 2007,
European Committee for Interoperable Systems The European Committee for Interoperable Systems (ECIS) is an international non-profit association founded in 1989 in order to promote interoperability and market conditions in the Information and Communications Technology (ICT) sector allowing vigo ...
(ECIS) – a coalition of mostly American software companies – accused Microsoft of attempting to hijack HTML and replace it with XAML, thus creating a vendor lock-in.
Jeremy Reimer, writing for ''
Ars Technica
''Ars Technica'' is a website covering news and opinions in technology, science, politics, and society, created by Ken Fisher and Jon Stokes in 1998. It publishes news, reviews, and guides on issues such as computer hardware and software, sc ...
'' described this comment as "the most egregious error" and added that XAML is unlikely to ever replace HTML.
See also
*
List of user interface markup languages
*
Comparison of user interface markup languages:
*
EMML
*
FXML
*
MXML
*
XPS
*
XUL
*
ZUML
ZK is an open-source Ajax Web application framework, written in Java, that enables creation of graphical user interfaces for Web applications with little required programming knowledge.
The core of ZK consists of an Ajax-based event-driven mechan ...
*
Interface Builder
*
Layout manager
References
External links
XAML Language ReferenceXAML for UWP: OverviewXAML for WPF: OverviewSystem.Windows.Markup NamespaceSystem.Xaml Namespace
{{Document markup languages
.NET terminology
Declarative markup languages
Declarative programming languages
Markup languages
Microsoft application programming interfaces
Microsoft Windows multimedia technology
User interface markup languages
Vector graphics markup languages
XML-based standards