Welcome!

.NET Authors: Liz McMillan, Mark O'Neill, Peter Silva, Yakov Werde, Matthew Pollicove

Related Topics: .NET

.NET: Article

The Xamlon Story

.NET code + XAML markup = Flash SWF

The codebase statement tells the browser to download the Flash player if one is not already installed on the machine. Depending on browser security settings, the user may be prompted for this download or shown a message indicating that content is blocked. In most cases, the player is already available and movie file is loaded immediately (see Figure 10).

Adding graphics to XAML is a snap. There are several elements in the revised app.xaml file. The rectangle creates a box with a gradient fill. The ellipse draws a blue shape, a given coordinate. The textbox places text as needed. The panel has a set of paths that combine to form an airline seat. These were copied from one of the Xamlon samples. Paths can be generated from an existing SWF or an Illustrator file. The Panel is used to position the seat (see Listing 2). Compiling this version results in the flashy dialog shown in Figure 11.

Imperative programming can be mixed with the declarative XAML design. Add an Image control (JPG and PNG, not GIF) and set the source and location. This code, when added to the button click event, dynamically loads a JPG that displays at a defined coordinate. Flash movies can be loaded in the same fashion offering some interesting animation possibilities:


desktop = desktop.GetDesktop()
Xamlon.Internal.Utilities.SetIndex(-10)
Dim i As New Image
i.Source = "billjwolff.jpg"
i.X = desktop.Width - 100
i.Y = desktop.Height - 150
desktop.AddChild(i)
The picture displays at the lower right corner because the desktop size was used to calculate the X and Y coordinates. Figure 12 shows the finished canvas.

A Complex Web-Driven App - AFLAX
There is an excellent stock market ticker sample included in the Xamlon Web install. The AFLAX design pattern is used to create an animated view of real-time data feeds. One project runs server side to deliver XML data to the client. It uses an ASPX page with content type set to text/xml. An XML list of stock tags is loaded into an arraylist. For each stock, HttpWebRequests connect to the Yahoo Finance sight to collect real-time data. The data is packaged as XML and sent to the client.

The client uses XAML to dress the window frame and a series of graphic images to display historical charts. A timer object fires an event that makes a background call to the server page to retrieve the latest XML. The data drives some graphic primitives that create the real-time chart. Figure 13 shows the finished product, all packaged in a tidy 73K SWF file.

Xamlon Futures
XAML will be a major component of every developer's toolbox in the next few years. Microsoft promises a WinFX release that will deliver parts of Avalon and XAML to Windows XP and Windows Server 2003 early next year. Xamlon technology gets you there today.

Xamlon Web has a compelling value proposition. Compiling next year's declarative markup technology with today's popular .NET languages to produce the ubiquitous SWF file format is a great way to deliver leading edge applications. Xamlon Web is scheduled for release this summer. Watch their Web site (www.xamlon.com) for details.

More Stories By Bill Wolff

Bill Wolff is an independent consultant, trainer, and architect specializing in Microsoft development technologies. His company, Agility Systems, is based in the Philadelphia area. He ran the consulting firm Wolff Data Systems for 15 years and directed armies of consultants in the dot com world. Bill is founder and President of the philly.net user group, board member for INETA (Vice President, Speaker Bureau), and he is active in several other user communities. Bill was a contributing author to several books and articles and he currently writes for .NET Developer's Journal. His certifications include trainer, systems engineer, developer, and Microsoft MVP for VB.NET.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.