Because XAML is a generalized markup language, it's been adopted by many Microsoft frameworks. This tutorial looks at the various XAML implementations. You’ll see how each framework defines a set of mappings that describe how the XAML elements and attributes map to their framework counterparts.
- [Narrator] Because XAML is a generalized markup language, it's been adopted by many Microsoft frameworks. Each framework defines a set of mappings that describe how the XAML elements and attributes map to their framework counterparts. XAML has parsers and compilers that turn the XML into binary artifacts, which become part of the application binary files. These binaries are executed when the app runs, just like normal binaries. The XAML parsers/compilers exist for two option-oriented systems, .NET and Windows Runtime.
In the .NET camp there are several XAML flavors that emerged at the time of the first release. Windows Presentation Foundation is useful for building dynamic, rich desktop applications. Windows Communication Foundation is a framework for building service-oriented applications. It focuses on the communicational layers between application parts. Windows Workflow is an attempt to create scalable applications by modeling application or process workflows. Silverlight is a technology with much promise. However, it's glory days are now in the past. It provides a rich UI development framework similar to WPF that works across multiple platforms.
In Silverlight for the web, the app was runable on Windows and Macs and it ran in most browsers. Later, Microsoft used Silverlight as a bridge technology to jump-start their new Windows Phone platform. When Microsoft rebooted the Windows UI in Windows 8, XAML was a key factor in the Windows Store app model. Now in Windows 10, there is yet another name. This time it's Universal Windows applications, or UWA. UWA is a vary promising accomplishment. Microsoft has finally unified its Windows operating system and its programming model to work across all the devices that run Windows.
That could be tablets, phones, Xbox One, desktops and more. .Net has a long history at Microsoft, and it's a core component of millions of Windows applications. A few years ago, Microsoft created a successor to .Net called Windows Runtime, or WinRT. WinRT applications fall into two general categories, Window Store apps intended for the Windows 8 and 8.1 operating systems, and the universal Windows applications intended for Windows 10. You may have noticed that these two items appeared in the .Net category, too.
WinRT works well with .Net, so you see them both here. Don't worry too much about the distinction. You can get more details in my Universal Windows Application course. The main point I wanna make is that all these frameworks shown use XAML. Since there are many XAML versions, you expect there must be a way to indicate which XAML parsers to use, and what mappings to use. To get the correct mappings, each version of XAML has a URI associated with it. You can see this in the XML. It's used in the XML namespace declaration. Line two contains an XML namespace declaration.
I'll discuss namespaces in more detail soon. The line starts with xmlns, the abbreviation for XML namespace. Then you see the URI in the double quotes on the end of the line. This URI describes the version of XAML used in this application. There's another xmlns on line three, but I'll delay talking about that for the moment. The key concept here is that each flavor of XAML will have a different URI in the root element. Most of the time, it's not something you need to worry about because Visual Studio creates the correct XMLNS declaration in the XAML file, based on your project type.
In most of the time, this URI shown on line two is the only one you need to understand. Here's why: This was the original URI back when WPF was first released. Later, when newer versions of WPF appeared, Microsoft defined a different URI that identified the new version. But they also supported the old URI version. Meaning you could use either. Eventually, Silverlight appeared, and it also has a new URI. Here's an example shown on line eight. See how the text is different than the declaration on line two? But here's the important part.
Microsoft learned that they could ship new frameworks that targeted newer libraries, and yet keep the old, original URI. So the one shown on line two is the one you'll see in most XAML files. To bring this movie to a close, XAML is used in many frameworks. So understanding the fundamentals of XAML syntax will prove useful no matter which framework you find yourself working in.
- What is XAML?
- What frameworks use XAML?
- Working with XAML and Visual Studio
- Exploring XAML namespaces
- Instantiating objects
- Subscribing to events
- Using XAML in Windows Presentation Foundations, Universal Windows, and more