#66 – XAML Elements Map to Instances of .NET Types
September 16, 2010 Leave a comment
As with XML, an element in XAML is a chunk of XAML that is enclased by angle brackets (<, >). The element may consist of both a start tag and and end tag (e.g. <Button></Button>) or an empty-element tag (e.g. <Button/>).
The text in the start tag, immediately following the left angle bracket (<) is known as the element name.
In XAML, this element name is the name of a .NET type and the XML element is known as an object element.
A object element in XAML represents an instance of a .NET class. At run-time, a new instance of a .NET type will be created for each object element found in a .xaml file.
For example, the follow XAML fragment defines three object elements of type Button.
<Button Content="Top" Height="23" Name="button1" Width="75" /> <Button Content="Middle" Height="23" Name="button2" Width="75" /> <Button Content="Bottom" Height="23" Name="button3" Width="75" />
At run-time, three instances of the Button type will be created when this XAML fragment is loaded.