Extensible Application Markup Language
Filename extension |
|
---|---|
Internet media type | application/xaml+xml |
Developed by | Microsoft |
Initial release | November 2006[1] |
Latest release | v2019 (12 March 2019[2]) |
Type of format | User interface markup language |
Extended from | XML |
Extensible Application Markup Language (XAML /ˈzæməl/ (listen)) is a declarative XML-based language developed by Microsoft for initializing structured values and objects. It is available under Microsoft's Open Specification Promise.[3]
XAML is used extensively in Windows Presentation Foundation (WPF), Silverlight, Workflow Foundation (WF), Windows UI Library (WinUI), Universal Windows Platform (UWP), and .NET Multi-platform App UI (.NET MAUI). In WPF and UWP, XAML is a user interface markup language to define UI elements, data binding, and events. In WF, however, XAML defines workflows.
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.[4]
Technology
XAML originally stood for Extensible Avalon Markup Language, Avalon being the code-name for Windows Presentation Foundation (WPF).[5] Before the end .NET Framework 3.0 development, however, Microsoft adopted XAML for Workflow Foundation (WF).[5]
In WPF, XAML describes visual user interfaces. 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,[5][6] 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 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".[7]
XAML uses a specific way to define look and feel called Templates; differing from Cascading Style Sheet syntax, it is closer to XBL.[8]
To create XAML files, one could use Microsoft Expression Blend, Microsoft Visual Studio, the hostable WF visual designer, or XAMLPad.[9]
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/2010" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <TextBlock>Hello, world!</TextBlock> </Canvas>
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[10]
<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.[11] 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 three main Microsoft implementations of XAML:
- Windows Presentation Foundation (WPF), first available with .NET Framework 3.0
- Silverlight 3 and 4, first available for Internet Explorer 6 and now deprecated
- Windows UI Library (formerly UWP XAML and WinRT XAML), first shipped with Windows 8 and Windows Server 2012, but now available as a part of the Windows App SDK
These versions have some differences in the parsing behavior.[12] 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.[13]
Response from the competition
In 2007, European Committee for Interoperable Systems (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.[14][15] Jeremy Reimer, writing for Ars Technica described this comment as "the most egregious error" and added that XAML is unlikely to ever replace HTML.[15]
See also
References
- ↑ "[MS-XAML Xaml Object Mapping Specification 2006"]. Microsoft. June 2008. https://download.microsoft.com/download/0/a/6/0a6f7755-9af5-448b-907d-13985accf53e/%5BMS-XAML%5D.pdf.
- ↑ "Extensible Application Markup Language (XAML)". Microsoft. 12 March 2019. http://www.microsoft.com/downloads/details.aspx?FamilyID=52a193d1-d14f-4335-aa86-c53193e1885d&displayLang=en.
- ↑ "Microsoft adds XAML to 'Open Specification' list – Software Development Times On The Web". http://www.sdtimes.com/(X(1)S(kw21wu45u03kzpnafqlanyiy))/content/article.aspx?ArticleID=31886&AspxAutoDetectCookieSupport=1.
- ↑ "XAML Syntax In Detail". Microsoft. 12 August 2021. https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/xaml-syntax-in-detail?view=netframeworkdesktop-4.8.
- ↑ 5.0 5.1 5.2 Rob Relyea : January 2004 – Posts
- ↑ unknown (2009-07-30). "What is BAML?". DOTNET Spider. http://www.dotnetspider.com/forum/216053-What-BAML.aspx. "BAML means Binary Application Markup Language, which is a compiled version of the XAML. When you compile your XAML it creates the BAML file."
- ↑ Andrew, Paul (25 January 2006). "xoml or xaml?". Microsoft. https://social.msdn.microsoft.com/Forums/en-US/590589ef-fdf0-4a1c-86b9-1cc7ad65df31/xoml-or-xaml?forum=windowsworkflowfoundation. ""Workflow programs (or models) are saved in the XAML format which is common to Avalon for serializing .NET types as XML. Avalon XAML is all about UI and Workflow XAML is all about business process so there's quite a semantic difference. The XOML file extension looks to remain for Workflow models though the file format is XAML.""
- ↑ Guthrie, Scott (22 February 2008). "Silverlight Tutorial Part 7: Using Control Templates to Customize a Control's Look and Feel". https://weblogs.asp.net/scottgu/silverlight-tutorial-part-7-using-control-templates-to-customize-a-control-s-look-and-feel.
- ↑ Avery, James; Holmes, Jim. "3.3 Writing XAML in XamlPad - Windows Developer Power Tools [Book"] (in en). O'Reilly. https://www.oreilly.com/library/view/windows-developer-power/0596527543/ch03s04.html.
- ↑ Microsoft XAML Overview page at XAML Overview (Root element and xmlns)
- ↑ Windows Presentation Foundation on the Web: Web Browser Applications - MSDN
- ↑ "XAML Processing Differences Between Silverlight Versions and WPF". Microsoft. 17 November 2011. https://docs.microsoft.com/en-us/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc917841(v=vs.95). "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."
- ↑ "XAML Processing Differences Between Silverlight Versions". Microsoft. 17 November 2011. https://docs.microsoft.com/en-us/previous-versions/windows/silverlight/dotnet-windows-silverlight/ff457753(v=vs.95).
- ↑ Beer, Stan (28 January 200). "Microsoft runs into EU Vista charges". http://www.itwire.com/it-industry-news/strategy/8988-microsoft-runs-into-eu-vista-charges.
- ↑ 15.0 15.1 Reimer, Jeremy (26 January 2007). "European committee chair accuses Microsoft of hijacking the web". Ars Technica. Condé Nast. https://arstechnica.com/uncategorized/2007/01/8715/.
External links
- XAML Language Reference
- XAML for UWP: Overview
- XAML for WPF: Overview
- System.Windows.Markup Namespace
- System.Xaml Namespace
Original source: https://en.wikipedia.org/wiki/Extensible Application Markup Language.
Read more |