#68 – Nesting XAML Elements Expresses Containment

Nesting elements is a fundamental part of XML syntax.  In XAML, nested elements typically expresses containment:

the .NET object corresponding to the child element is contained in the .NET object corresponding to the parent element.

Here’s an example.  The XAML fragment below defines a StackPanel control that contains two Button controls.

<StackPanel Height="100" Name="stackPanel1" Width="200">
    <Button Content="Button" Height="23" Name="button1" Width="75" />
    <Button Content="Button" Height="23" Name="button2" Width="75" />
</StackPanel>

The structure of the XAML elements (Button as child of StackPanel) mirrors the structure of the actual controls in the user interface (the buttons are children of the StackPanel).

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 131 other followers