Tutorials » WPF tutorials »

Introduction to XAML

This article explains in brief about XAML.

Previously you learn the tools, techniques and some important classes of WPF. We can develop GUI of our application using WPF in two ways, the common drag and drop method and using the XAML code. XAML is a new technique to develop GUI for applications whose syntax is quite similar to XML. In this chapter you are going to learn about XAML in brief.

Before going to the topic you may have one doubt, why to use XAML? The answer is quite simple. In XAML we have the power to work with 3D, multimedia and animations which are not possible through the traditional method. Hence to develop better GUI using WPF we need to learn WPF. So let’s start the topic.

Introduction to XAML:-

Extensible Application Markup Language(XAML) is a new XML based code that allows you to define the different functionality of a .NET type through markup mainly in WPF. As XAML is a XML based technique we have all the advantages and disadvantages of XML. Some of the advantage and drawbacks of XAML are,

--> XAML is self describing.
--> XAML files represent each element as a type name such as button, window, etc.
--> XAML is case sensitive like XML.

One of the major advantages of XAML is that it improves the collaboration between designers and developers. Microsoft describes XAML as “toolable” that means XAML can be manipulated using software tools.
This helps the separation of the GUI design from implementation. Products like Microsoft’s Expression can be used to design the GUI and generate the XAML code. Then this code can be imported to a development environment like Visual Studio by the developers.

How it works:-

In XAML most of the interfaces have representations and each property is represented by an XML element and/or attribute.

XAML file contains all the information about the window and its components itself.

Each element in XAML is organised in a hierarchical manner making it easy for the programmer to add or delete codes easily at any time.

XAML in terms of its relationship to CLR objects and types, WPF defines types that represent controls and other UI elements and the XAML simply maps to that types.
Below is a simple code to create a button in XAML.
<!- -Define Button in XAML- - >
<Button Name="btnClick"
Content="Click Me"/>

It can be programmatically done like,
Button btnClick=new Button();
btnClick.Content="Click Me";

From the above example it is clear that using XAML is much easier.

What's Next?

In the next chapters you will learn how to work with different common elements of the window in XAML. You will also learn how to work with Graphics, multimedia and animation gradually. Please be patience.

Previous Chapter: Some Important Classes and Namespaces
More Chapters: WPF Tutorials
More Tutorials: Tutorial Index

Top Contributors
    Last 7 Daysmore...

    Awards & Gifts

    Online Members

    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India