|
|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS XAML
Unleash the Power of XAML and Windows Presentation Foundation, Today
Use the new declarative format to build new Windows GUIs
By: Ron DeSerranno
Dec. 7, 2005 11:30 AM
Digg This!
In today's world new technology is introduced daily. At times, a little bell goes off in your head and you think to yourself, "This will change everything." This has happened to me a few times. When I saw my first CD I knew that the days of my good old 8-Track and cassettes were numbered. I've been involved in technology for two decades, so I've seen it happen in software as well. Using text-based applications like GOPHER was cutting edge when I saw my first HTML page loaded into a Web browser. I knew then that my Internet experience would never be the same. This article is going to explain why "bells" are ringing internationally with what's coming down the pike from Microsoft.
At the 2003 Microsoft PDC Conference "Avalon" and "XAML" were unveiled. Avalon (Now WPF, Windows Presentation Foundation) was a new graphics engine and API on which the next version of Windows would be built. Unlike GDI, this engine was built on top of DirectX and was hardware accelerated. XAML was a declarative XML-based markup language that could be used with the Avalon graphics engine. After some initial investigation, I was in love. Avalon and XAML had all of the capabilities that SVG had, such as vector graphics and 2D animation. However, it also treated user interface controls as first class citizens and had an XML-based styling mechanism. In addition, it had an XML binding syntax for attaching live data to Avalon objects. Within a month of the PDC we had refocused our business on Avalon and XAML. In time Microsoft unveiled more capabilities of Avalon and XAML. That little bell in my head was ringing wildly. Today the capabilities of XAML and WPF are very extensive. XAML is supported on Windows XP and Windows 2003 Server with WinFX installed, and natively in Windows Vista. The advantages XAML provides over traditional technology are summarized in the following list:
Is your "bell" starting to ring as well? It is not hard to start using this revolutionary technology today. I am going to give a brief overview of XAML in order to get your feet wet. If you are using .NET, XAML will be an easier transition. If you are looking for more information, there are resources available at bookstores such as Wrox's Professional WinFX Beta: Covers "Avalon" Windows Presentation Foundation and "Indigo" Windows Communication Foundation. There is also extensive information available on-line; www.XAML.net and www.mobiform.com also have great information, resources, and tools. To start with XAML, you will require the latest WinFX SDK from Microsoft. Free beta updates are available on www.microsoft.com. WinFX runs on Windows XP, 2003, and Vista. From there you can start to work with XAML and WPF in a few ways. The first is to install Visual Studio 2005 on your computer. When you start Visual Studio you will see some new WPF project types. Select a new WPF Application. These would be "Avalon Application" and "Avalon Web Browser Application," as indicated in Figure 1. The code-behind file and the XAML file are displayed in Visual Studio as seen in Figure 2. The XAML file is where the user interface controls are defined. The second way to get started easily with XAML is by downloading a XAML Design tool like the Aurora, XAML Designer for WinFX. Using Aurora means you don't have to manually code XAML. Aurora leverages the power of XAML and WPF to deliver XAML 2D and 3D graphics and documents. It will display the XAML syntax as you are marking up the document. You can also use Aurora with the XAML documents from Visual Studio, as shown in Figure 3. Basic XAML and WPF usage is actually quite simple. For 2D graphics, Microsoft made WPF quite similar to SVG in syntax. Figure 4 shows a Canvas with a Rectangle, Ellipse, and Line. The sample demonstrates how XAML allows for several brush types, gradients, and rotation. As XAML produces Vector Images, had I included text on the yellow and red rectangle, there would have been absolutely no degradation in the text. Listing 1 shows the code behind this sample. For user interfaces, WPF has all of the common WinForms controls like Button, Checkbox, List Box, Combo Box, and Tab Controls. Custom controls can also easily be created and shared. Figure 5 shows some typical WPF controls. Listing 2 shows the code. Creating these forms is very easy when using a tool such as Aurora. One of the most important concepts in WPF is the Dependency Property System. Dependency properties are very common in WPF. Most public properties on WPF on objects have a corresponding static dependency property. The dependency property is used as a key in locating the value of the object you are looking for. If we were to try and prototype a sample of a dependency property and the dependency property sub system in WPF, it may look something like Listing 3. In addition to regular dependency properties there are "Attached" dependency properties. These are static dependency properties that belong to one class but can be used in another. Consider the following XAML code snippet:
<Rectangle Fill="#FF0000FF" Height="72" Canvas.Left="74" Stroke="#FF000000" The Fill, Height, Width, and Stroke are all regular dependency properties of the Rectangle or one of its base classes. The Canvas.Top property is an Attached dependency property. This property belongs to the Canvas class, but is used by the rectangle class to specify its X and Y position within a Canvas. Attached Dependency Properties are typically seen when working with the Canvas, Grid, and DockPanel classes in Avalon, but there are others as well. Dependency properties are a key part of WPF. Animation, data binding, and styling are all executed on dependency properties. XAML doesn't stop there. I have only touched the surface. One last thing I will briefly explain is 2D animation. Listing 3 shows some basic 2D animation in XAML. WPF is built on top of DirectX and is hardware accelerated, so the graphics are very fast and smooth. Because it is difficult to show animation in an article, I will just show you a code snippet after the object has been created. It happens to be a bouncing red ball. These are just small examples of the power of XAML and WPF. This article has not even touched on 3D, ink canvas, audio, video, styling, data binding, and the many other capabilities of XAML. In a nutshell, XAML and WPF will change the way we develop, design, and experience applications, documents and Web sites. The future is XAML because it:
MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
||||||||||||||||||||||||||||