XAML—Loading and Compiling XAML


Jump to: navigation, search
Visual C# Tutorials
.NET Framework Tutorials

XAML

© 2007 Matthew MacDonald

Loading and Compiling XAML

As you’ve already learned, XAML and WPF are separate, albeit complementary, technologies. As a result, it’s quite possible to create a WPF application that doesn’t use the faintest bit of XAML.

Altogether, there are three distinct coding styles that you can use to create a WPF application:

  • Code-only. This is the traditional approach used in Visual Studio for Windows Forms applications. It generates a user interface through code statements.
  • Code and uncompiled markup (XAML). This is a specialized approach that makes sense in certain scenarios where you need highly dynamic user interfaces. You load part of the user interface from a XAML file at runtime using the XamlReader class from the System.Windows.Markup namespace.
  • Code and compiled markup (BAML). This is the preferred approach for WPF, and the one that Visual Studio supports. You create a XAML template for each window and this XAML is compiled into BAML and embedded in the final assembly. At runtime the compiled BAML is extracted and used to regenerate the user interface.

In the following sections, you’ll dig deeper into these three models and how they actually work.


Previous_Page_.gif Next_Page_.gif





Personal tools