Tuesday, January 27, 2009

XAML in .net : A Step Ahead Series

XAML : stands for eXtensible Application Markup Language and pronounced as zammel".

XAML combined with the next-gen Windows graphics kernel (code-named Avalon) is an all-in-one markup language for hypertext (HTML), vector graphics (SVG), animations (Flash,SMIL), print documents (PDF,XSL-FO), forms (XForms,XUL), and much more.

The best of both worlds: In the XAML world there's no longer a difference between a web application and a windows application. Windows is the browser kernel and Internet Explorer is just a shell.

The best of all worlds: A single programming model for media, documents and applications.

A typical XAML example:


<Window Text="Xul Challenge 2004">
<FlowPanel>
<SimpleText>Counter Sample</SimpleText>
<TextBox ID="ValueTextBox" HorizontalAlignment="Center" IsReadOnly="True"/>
<FlowPanel HorizontalAlignment="Center" Width="100%">
<Button Click="Dec">Dec (-)</Button>
<Button Click="Clear">Clear</Button>
<Button Click="Inc">Inc (+)</Button>
</FlowPanel>
</FlowPanel>
</Window>



<b>C# vs. XAML</b>

1. XAML-Example
<TextPanel
Background="BlanchedAlmond"
FontFamily="Comic sans MS"
FontSize="36pt"
HorizontalAlignment="Center">
Hello, world!
</TextPanel>

2. C#-Example

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

class HelloWorldApp : Application
{
static void Main()
{
HelloWorldApp app = new HelloWorldApp();
app.Run();
}

protected override void OnStartingUp( StartingUpCancelEventArgs args )
{
Window win = new Window();
TextPanel tp = new TextPanel();

tp.Background = Brushes.BlanchedAlmond;
tp.FontFamily = "Comic sans MS";
tp.FontSize = new FontSize( 36f, FontSizeType.Point);
tp.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
tp.TextRange.Text = "Hello, world";

win.Children.Add(tp);
win.Show();
}
}



For more details, please refer to:

1. http://msdn.microsoft.com/en-us/library/ms752059.aspx
2. http://xaml.sourceforge.net/talk/dotnet-dec-2004/slides.html

No comments:

Post a Comment