1. In order to compile, XAML code must be mapped to .NET Namespaces. Normally, when writing XAML you define XML namespaces to accomplish this.
The XML namespace that maps to various .NET controls is xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/[presentation”
To see the exact many to one mappings refer to page 23 of Windows Presentation Foundation Unleashed (WPFU).
A secondary namespace that is frequently mapped with a prefix (usually x) and that maps XAML language namespace to the System.Windows.Markup .NET namespace is xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
2. Some properties of a XAML object can be set using both Property Attribute syntax and Property Element syntax
The following two code XAML code snippets are equivalent.
Property Attribute Syntax
<Button Content="OK" />
Property Element Syntax
<Button>
<Button.Content>
OK
</Button.Content>
</Button>
Complex types will often require the use of the Property Element syntax
3. For all of this to work, WPF defines Type Converters that can convert simple strings into .NET complex types.
For example, Type Converters convert the White string in the following XAML
<Button>
<Button.Background>
White
</Button.Background>
</Button>
into the System.Windows.Media.SolidColorBrush type (specifically the static field of System.Windows.Media.Brushes.White)
4. Type converters inherit from the System.ComponentModel.TypeConverters class.
Many type converters are available for common .NET classes such as Brush, Color, FontWeight, Point, and so on. You can also write custom Type converters for your own custom types.
5. Like, Type Converters, Markup Extensions exist to extend the expressability of XAML and WPF ships with multiple Markup Extensions built in.
The MarkupExtension abstract class exists in the . System.Windows.Markup namespace.
For a list of MarkupExtension classes see the inside front cover of WPFU
Markup Extensions have a more explicit and consistent syntax and are the preferred way of extending XAML.
Markup Extensions are used in XAML attributes (or elements) by referencing the values in curly braces ({}) as shown in the following XAML
<Button Background=”{x:Null}” />
In this example you cannot set a Button background to Null because this is not supported by the Type Converter. But by using the NullExtension Markup extension you can. Notice that in the XAML you truncate the Extension part of the Markup extension class.