Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Panel Content Model Overview

This content model overview describes the supported content for a Panel. StackPanel and DockPanel are examples of Panel objects.

This topic contains the following sections.

A Panel has the following content properties.

The Children property can contain multiple objects, even other Panel objects. The following example shows how to use the Children property to add two Button objects to a StackPanel.

<Page  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    <Button>Button 1</Button>
    <Button>Button 2</Button>
using System;
using System.Windows;
using System.Windows.Controls;

namespace SDKSample
    public partial class StackpanelExample : Page
        public StackpanelExample()
            // Create two buttons
            Button myButton1 = new Button();
            myButton1.Content = "Button 1";
            Button myButton2 = new Button();
            myButton2.Content = "Button 2";

            // Create a StackPanel
            StackPanel myStackPanel = new StackPanel();

            // Add the buttons to the StackPanel

            this.Content = myStackPanel;

Community Additions

© 2015 Microsoft