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">
<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>

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

1. XAML-Example
FontFamily="Comic sans MS"
Hello, world!

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();

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";


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