100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
.NET

What Is XAML?

An introduction to XAML (Extensible Application Markup Language), the declarative XML-based language Microsoft frameworks use to define user interfaces and object graphs.

FoundationsBeginner7 min readJul 10, 2026
Analogies

What Is XAML?

XAML (Extensible Application Markup Language) is a declarative, XML-based markup language created by Microsoft for defining user interfaces and object hierarchies in .NET applications. Instead of writing C# code that calls constructors and sets properties line by line, a developer writes XML elements that describe what the UI should look like, and a XAML parser translates that markup into an object graph at compile time or runtime. XAML powers UI frameworks including WPF, UWP, Xamarin.Forms, and .NET MAUI, and it is also used to describe non-visual resources such as styles, templates, and animations.

🏏

Cricket analogy: XAML is like a pre-submitted team sheet handed to the match referee before a Test at Lord's, declaring Rohit Sharma as opener and Bumrah as strike bowler, instead of shouting substitutions live over the boundary rope.

Why XAML Exists

XAML was designed to separate the declarative description of a UI from the imperative logic that drives it, letting designers work in tools like Blend while developers write C# or Visual Basic in the same project. Because XAML is just XML, it can be generated, parsed, and edited by tooling without executing any code, which is what enables the live visual designer and design-time preview in Visual Studio. This separation also makes UI structure easier to review, diff in source control, and restyle without touching application logic.

🏏

Cricket analogy: It's like how a curator prepares the pitch report (grass cover, expected turn) separately from the captain's bowling strategy, so groundstaff and coaches can each do their job without stepping on each other's decisions.

XAML as an Object Graph

Every XAML element corresponds to an instantiable .NET class, and every attribute corresponds to a property or event on that class. When the XAML parser reads a file, it walks the element tree, creates an instance for each element using its default constructor, converts attribute strings into the correct property types, and nests child objects according to the XML structure, ultimately producing the same object graph you would get by writing equivalent C# by hand.

🏏

Cricket analogy: It's like a scorecard being expanded into a full match report: each entry (batsman, runs, balls faced) maps directly to a database record, just as each XAML element maps to a constructed .NET object.

xml
<Window x:Class="DemoApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Demo" Height="200" Width="300">
    <Grid>
        <Button Content="Click Me" Width="120" Height="32"
                HorizontalAlignment="Center" VerticalAlignment="Center"
                Click="OnButtonClick" />
    </Grid>
</Window>

XAML is entirely optional in most frameworks that support it — everything a XAML file produces (a Window with a Grid containing a Button) can also be written by hand in C# using constructors and property assignments. XAML is simply a more concise, tool-friendly, and designer-friendly way to express the same object graph.

Where XAML Is Used

XAML is not limited to a single framework: WPF and UWP use it for desktop and Windows Store apps, Xamarin.Forms and its successor .NET MAUI use a XAML dialect for cross-platform mobile and desktop UI, and Silverlight used an earlier variant for browser-based applications. Beyond top-level windows and pages, XAML is used pervasively for ResourceDictionaries, ControlTemplates, DataTemplates, and Storyboards, meaning a large share of the visual and behavioral definition of a modern .NET client application lives in .xaml files rather than in code.

🏏

Cricket analogy: It's like the toss protocol being used identically across formats — Tests, ODIs, and T20Is all start with a coin flip and a captain's call — even though the surrounding rules of each format differ.

  • XAML is a declarative, XML-based markup language for building UI and object graphs in .NET applications.
  • It separates UI structure (XAML) from imperative logic (C#/VB), enabling parallel designer and developer workflows.
  • Every XAML element maps to a .NET class instance; every attribute maps to a property or event.
  • The XAML parser converts markup into an object graph identical to hand-written equivalent code.
  • XAML is used in WPF, UWP, Xamarin.Forms, and .NET MAUI, as well as in resource dictionaries and templates.
  • Using XAML is optional — any XAML-defined UI could be constructed entirely in code instead.

Practice what you learned

Was this page helpful?

Topics covered

#NET#XAMLStudyNotes#MicrosoftTechnologies#WhatIsXAML#XAML#Exists#Object#Graph#StudyNotes#SkillVeris