Extensible Application Markup Language

Extensible Application Markup Language (XAML /ˈzæməl/ (listen)) is a declarative XML-based language developed by Microsoft that is used for initializing structured values and objects. It is available under Microsoft's Open Specification Promise.[4] The acronym originally stood for Extensible Avalon Markup Language, Avalon being the code-name for Windows Presentation Foundation (WPF).[5]

Extensible Application Markup Language (XAML)
Filename extension
.xaml
Internet media type
application/xaml+xml
Developed byMicrosoft
Initial releaseJune 2008 (2008-06)[1]
Latest release
v2009
(16 April 2010 (2010-04-16)[2][3])
Type of formatUser interface markup language
Extended fromXML

XAML is used extensively in .NET Framework 3.0 & .NET Framework 4.0 technologies, particularly Windows Presentation Foundation (WPF), Silverlight, Windows Workflow Foundation (WF), Windows Runtime XAML Framework and Windows Store apps. In WPF, XAML forms a user interface markup language to define UI elements, data binding, events, and other features. In WF, workflows can be defined using XAML. XAML can also be used in Silverlight applications, Windows 10 Mobile (previously Windows Phone) and Universal Windows Platform apps, also called Windows Store apps.

XAML elements map directly to Common Language Runtime 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, and the hostable Windows Workflow Foundation visual designer. They can also be created and edited with a standard text editor, a code editor like XAMLPad, 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.[6] 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. XAML also benefits from being a declarative definition of the UI rather than procedural code to generate it.

Technology

A XAML file can be compiled into a .BAML file (Binary Application Markup Language[7]), 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 interfaces. 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 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".[8][9]

Templates

XAML uses a specific way to define look and feel called Templates; differing from Cascading Style Sheet syntax, it is closer to XBL.[10]

Example

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

<Canvas xmlns="http://schemas.microsoft.com/client/2007"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <TextBlock>Hello, world!</TextBlock>
</Canvas>

The schema (the xmlns="https://web.archive.org/web/20170705010515/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[11]

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  <TextBlock>Hello, world!</TextBlock>
</Canvas>

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 page; rather it must be loaded into the page via JavaScript. If .NET 3.0 or later is installed, loose XAML files can also be viewed on their own in a compatible Web browser (including Internet Explorer and Firefox) in conjunction with the .NET Framework 3.0, without the need for the Silverlight plugin.[12] Loose XAML files are markup-only files limited to defining the visual content to be rendered. They are not compiled with an application.

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>XAML Example</title>
    <script type="text/javascript" src="MySilverlight.js" />
    <script type="text/javascript" src="Silver.js" />
  </head>
  <body>
    <div id="MySilverlight" >
    </div>
    <script type="text/javascript">
      createMySilverlight();
    </script>
  </body>
</html>

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:

<TextBox x:Name="txtInput" />
<TextBlock Text={Binding ElementName=txtInput,Path=Text} />

Differences between versions of XAML

There are four Microsoft main implementations of XAML:

These versions have some differences in the parsing behavior.[13]

Additionally, the Silverlight 4 XAML parser is not 100% backward compatible with Silverlight 3 files. Silverlight 3 accepted XAML files may not be accepted or are parsed differently by the Silverlight 4 parser.[14]

Criticism of XAML GUI usage in Silverlight

The European Committee for Interoperable Systems said in 2007 that Microsoft's use of XAML in its Silverlight product aimed to introduce content on the World Wide Web that could only be accessed from the Windows platform.[15][16] Using a plugin, XAML is viewable in some non-Microsoft browsers on Windows, Linux, and Mac; and Microsoft supported Novell's Silverlight viewer for GNU/Linux called Moonlight.[17] As of January 2010, Moonlight 2 was compatible with Silverlight 2, but development of Moonlight was later discontinued.[18]

gollark: It's a bit misaligned or something.
gollark: Idea: use [ALGORITHMS] to group people into clusters of correlated responses and produce a new set of genders.
gollark: New gender axis: feelings about 100-axis gender model.
gollark: Wait, how come it defines gender along 100 axes but then gender attraction stuff using only THREE?
gollark: If you believe in yourself, you can <@356107472269869058> do anything.

See also

References

  1. [MS-XAML] – v1.0, Xaml Object Mapping Specification 2006 (PDF), Microsoft, June 2006, retrieved 2010-06-24
  2. [MS-XAML] – v2009, XAML Object Mapping Specification 2009 (PDF), Microsoft, April 2010, retrieved 2010-06-24
  3. Extensible Application Markup Language (XAML), Microsoft, 2010-04-16, retrieved 2010-06-24
  4. "Microsoft adds XAML to 'Open Specification' list - Software Development Times On The Web". Archived from the original on 2008-12-11. Retrieved 2008-04-17.
  5. Rob Relyea : January 2004 - Posts Archived 2007-10-11 at the Wayback Machine
  6. "XAML Syntax Terminology". Microsoft Corporation.
  7. unknown (2009-07-30). "What is BAML?". http://www.dotnetspider.com/: DOTNET Spider. BAML means Binary Application Markup Language, which is a compiled version of the XAML. When you compile your XAML it creates the BAML file.
  8. MSDN forum post by the WF product manager
  9. RuleML and BPEL are other examples of XML-based declarative logic languages
  10. Guthrie, Scott (2008-02-22). "Silverlight Tutorial Part 7: Using Control Templates to Customize a Control's Look and Feel". Retrieved 2008-03-08.
  11. Microsoft XAML Overview page at XAML Overview (Root element and xmlns)
  12. Windows Presentation Foundation on the Web: Web Browser Applications - MSDN
  13. "XAML Processing Differences Between Silverlight Versions and WPF". Microsoft. Retrieved 2011-10-02. Silverlight includes a XAML parser that is part of the Silverlight core install. Silverlight uses different XAML parsers depending on whether your application targets Silverlight 3 or Silverlight 4. The two parsers exist side-by-side in Silverlight 4 for compatibility. In some cases, the XAML parsing behavior in Silverlight differs from the parsing behavior in Windows Presentation Foundation (WPF). WPF has its own XAML parser.
  14. "XAML Processing Differences Between Silverlight Versions". Microsoft. Retrieved 2011-10-02.
  15. "Microsoft runs into EU Vista charges". itwire.com. 2007-01-28. Retrieved 22 August 2013.
  16. Reimer, Jeremy. "European committee chair accuses Microsoft of hijacking the web". Ars Technica. Condé Nast. Retrieved 22 August 2013.
  17. Foley, Mary Jo (2007-09-25). "Microsoft officially 'extends support' for Novell's Silverlight Linux port". zdnet.com. Retrieved 2007-10-13.
  18. "Releasing Moonlight 2, Roadmap to Moonlight 3 and 4". Miguel de Icaza. Retrieved 2009-12-17.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.