XAML (short for Extensible Application Markup Language, and pronounced "zammel") is a markup language used to instantiate .NET objects. Although XAML is a technology that can be applied to many different problem domains, its primary role in life is to construct WPF user interfaces. In other words, XAML documents define the arrangement of panels, buttons, and controls that make up the windows in a WPF application.
It’s important to understand that WPF doesn’t require XAML. There’s no reason Visual Studio couldn’t use the Windows Forms approach and create code statements that construct WPF windows. But if it did, window would be locked into the Visual Studio environment and available to programmers only.
The XAML standard is quite straightforward. Below are few ground rules:
- Every element in a XAML document maps to an instance of a .NET class. The name of the element matches the name of the class exactly.
- As with any XML document, one element can be nested inside another. However, nesting is usually a way to express containment.
- You can set the properties of each class through attributes. However, in some situations an attribute isn’t powerful enough to handle the job. In these cases, you’ll use nested tags with a special syntax.
- Declarative object syntax
- Use to define the static structure and configuration of an object hierarchy
- Not specific to WPF
- Easier to write development tools
- Relatively easy to edit and understand
- Expresses object hierarchies in a more compact form
- Objects must have default constructor
- Requires type conversion