Microsoft Cloud Authors: Pat Romanski, Andreas Grabner, Nick Basinger, Kevin Benedict, Liz McMillan

Related Topics: Microsoft Cloud

Microsoft Cloud: Article

Unleash the Power of XAML and Windows Presentation Foundation, Today

Use the new declarative format to build new Windows GUIs

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.

XML is one such technology that got my bells ringing. XML has worked its way into everything from WAP to Web services. Even casual computer users have come to at least recognize the term. When I was looking to start my current software business, I was introduced to XML-based graphics and animation in the form of W3C's SVG (Scalable Vector Graphics). I recognized then that one of the few areas not yet consumed by XML was graphics and multimedia. Having an XML-based file format filling this void was a sure bet. Back in 2002, SVG was the only XML-based graphics format. SVG seemed as though it would be quite successful, and our progress gained a lot of attention with SVG-interested parties. We were licensing our code for use in many graphical and visual applications. In time we had some major concerns: SVG was using CSS for styling (non-XML). it did not have user interface controls as first class citizens, the pace at which the W3C was moving on the specification seemed quite slow, and last, there didn't seem to be any major endorsement or plans for broad use by 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:

  • Creates 2D vector objects, complex curves, glyphs and 2D animation
  • Creates 3D objects and 3D animation
  • Simple styling and data binding
  • Audio and video support
  • Common user interface controls
  • Support for raster images with image effects
  • Panel types like Canvas, DockPanel, ViewBox, and StackPanel
  • Support for fixed format documents (PDF is a type of fixed format document)
  • Support for flow format documents and navigation with hyperlinks (an HTML page is a flow format document)
  • A document viewer control for loading and viewing external fixed and flow format XAML documents
  • Supports solid, linear gradient, radial gradient, image, drawing, and video brushes
  • Viewable in Internet Explorer 6 via Vista Express Applications
In addition to all of this, Microsoft unveiled a subset of XAML at the WinHEC 2005 known as "Metro." Metro is an XML-based markup syntax that would be used at the printer-driver level as a possible replacement for Postscript.

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"
Canvas.Top="77" Width="131" />

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:

  • Has all of the capabilities of HTML and Flash
  • Has equivalents for all common controls
  • Can produce fixed and flow format documents
  • Creates 2D and 3D graphics and animation
  • 100% XML
With Bells ringing globally, XAML is now more popular than ever. I am convinced XAML will revolutionize the user experience and those who choose to start today, will have a competitive edge tomorrow. Mobiform's Aurora XAML Designer for WinFX is making easy XAML design a reality. Have fun starting tomorrow, today.

More Stories By Ron DeSerranno

Ron DeSerranno is founder and president of MOBIFORM Software Inc. Ron is considered to be a leading authority on XML-based graphics
technologies. He has been designing and developing world-class software for over 15 years.

Comments (2)

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.

IoT & Smart Cities Stories
Moroccanoil®, the global leader in oil-infused beauty, is thrilled to announce the NEW Moroccanoil Color Depositing Masks, a collection of dual-benefit hair masks that deposit pure pigments while providing the treatment benefits of a deep conditioning mask. The collection consists of seven curated shades for commitment-free, beautifully-colored hair that looks and feels healthy.
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
We all love the many benefits of natural plant oils, used as a deap treatment before shampooing, at home or at the beach, but is there an all-in-one solution for everyday intensive nutrition and modern styling?I am passionate about the benefits of natural extracts with tried-and-tested results, which I have used to develop my own brand (lemon for its acid ph, wheat germ for its fortifying action…). I wanted a product which combined caring and styling effects, and which could be used after shampo...
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.