Oxygene and Windows Phone 8 tutorials – Article Index
What is XAML?
XAML stands for Extended Application Markup Language. It is a declarative Markup language which is generally used to create the user interface.
The XAML can be defined directly in the Visual Studio/Expression Blend XAML Editor or the designer.
Let’s take the MainPage.XAML file that is created when creating a new Windows Phone project as example. The MainPage.XAML file looks something like shown below.
Inside the MainPage.xaml, you will notice the series of attributes xmlns followed by colon followed by the name and = symbol and the path to the assembly.
This is the namespace “shell” which represents the Microsoft.Phone.Shell namespace from the Microsoft. Phone assembly. The namespaces are generally created automatically when the controls are created in the designer by dragging and dropping them from the toolbox. You can also manually add them as well.
To Create a Button, one can use the XAML tag with the attributes as shown below
<Button Name="btn1" Content="Click"></Button>
If you want to add the complex property, you can do that as well. For example, assume that you need to set the background color of the button to Blue.
You can do this by setting the Background property of the button as shown below
<Button Name="btn1" Background="Blue"> </Button>
The developers can also use the Nested / Complex attributes as shown below to set the background color.
<Button Name="btn1"> <Button.Background> <SolidColorBrush Color="Blue" /> </Button.Background> </Button>
Few attributes takes special kind of values surrounded by the curly brackets in XAML. For example , in the below screenshot , the style attribute takes the value Static Resource surrounded by curly braces. These kind of values are generally used to bind the data, static resources, style etc.