Fundamentals of XAML

In this blog you will learn about XAML.

What is XAML?

XAML --> Extensible Markup Language. XAML is very easy in use and it is tag based language. There are different tags that do their work. Today, I am going to give detail some of the tags of XAML, because they are easy to use and understand, and 1 can learn them easily. Before starting 1 thing kept in mind that it is tag based and when we open a tag mostly it is necessary to close the same tag as same in HTML. First of all we start from the easy and then move to some difficult. Tags are follow as below:

1. How to display a piece of word/Line/Whatever on the Screen?


  1. <TextBlock>HelloWorld!</TextBlock>  
Here the tag "TextBlock" is used for writng. Whatever that you have written in between the tags it is as similar prints on the screen. As in the above Hello World is written in between the tags so as same it print on the screen.

2. How we craete a Menu?

  1. <Menu IsMainMenu="True"></Menu>   
However it is necessary to tell about menu items. So for them the code is here:
  1. <MenuItem Header="_File" />  
  2. <MenuItem Header="_Edit" />  
  3. <MenuItem Header="_View" />  
  4. <MenuItem Header="_Window" />  
In Menu tag we create a menu and then we write some of its item as above written. Where its item is File other is edit etc.

And then we close the Menu tag.

3. How to add Secretors in the List?

  1. <Separator>......</Separator>   
It is necessary to tell the description with example.
  1. <Menu>  
  2.     <MenuItem Header="_File">  
  3.         <MenuItem Header="_New..." />  
  4.         <Separator />  
  5.         <MenuItem Header="_Open..." />  
  6.         <Separator />  
  7.         <MenuItem Header="_Save" />  
  8.         <MenuItem Header="_Save As..." />  
  9.         <Separator />  
  10.         <MenuItem Header="_Exit" />  
  11.     </MenuItem>  
  12. </Menu>  
As the syntax of the language is so much easy. No need to detail or explain the code. After all i will tell you how the above code works. there is a menu tag and inside the menu tag menuitem tag is used. and inside this separator tag is used it just mark a line in between the elements of Menu items.

4. How XAML works/deal with Password?

  1. <Label Content="Password:" />  
  2. <PasswordBox x:Name="abc" Width="90" />  
First we make a label and set its name to Password and after make a tag with passwordBox and inside it we set its name to abc ans set is width of the password label to 90.

Some of the function related. So use/try them by your own:
  1. <PasswordBox x:Name="ahtasham" PasswordChar="*" />  
  2. <PasswordBox x:Name="abc" MaxLength="10 />  
5. How to use Font, width and height?

  1. <Label Name="ahtasham" idth="200" Height="24FontSize="5" FontFamily="Georgia"/>  
It is so easy. Lets fun with it.