XAML in Silverlight


Introduction : This blog shows the advantages of Xaml language and how they used in silverlight application.

1.XAML can be used to mark up and define the layout of text and other controls on a user interface XAML is a richer language, offering the ability to create user interfaces in Windows.

2.XAML can be compiled, and it takes full advantage of the Longhorn graphics subsystem, helping developers to produce visual effects that once required Flash.
 XAML is very easy to use and ties up tightly with the underlying .NET Framework and classes.
XAML is pretty simple and straightforward, allowing us to create a user interface with very little code.

3.Each and every XAML element corresponds to a .NET Framework class and comes with a collection of methods, properties, and events. Adding a new
tag to the XAML file will instantiate the corresponding object at runtime.

4.In most applications, creating the user interface involves the lion's share of the coding. By using XAML for the user interface layer and a .NET language like C# or VB.NET for the logic and event handling, developers will be able to build an application that can be easily modified without mixing presentation and logic, as is now possible over the Web with ASP.NET. This approach gives developers greater flexibility and allows them to change the user interface without rewriting the logic.

5.using XAML for the user interface is that the hierarchies of the various controls on a user interface are pretty evident, unlike in the conventional programming language model. This makes the UI code much more understandable when compared to the earlier models.

6.XAML code is short and clear to read Separation of designer code and logic Graphical design tools like Expression Blend require XAML as source.

The separation of XAML and UI logic allows it to clearly separate the roles of designer and developer.

Example :

<StackPanel>
    <TextBlock Margin="20">Welcome to the World of XAML</TextBlock>
    <Button Margin="10" HorizontalAlignment="Right">OK</Button>
</StackPanel>

Markup extensions are dynamic placeholders for attribute values in XAML. They resolve the value of a property at runtime.

Namespaces:

At the beginning of every XAML file you need to include two namespaces.

The first is http://schemas.microsoft.com/winfx/2006/xaml/presentation. It is mapped to all wpf controls in System.Windows.Controls.

The second is http://schemas.microsoft.com/winfx/2006/xaml it is mapped to System.Windows.Markup that defines the XAML keywords.

  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Thanks.
Ebook Download
View all
Learn
View all