#971 – Items Property is a Content Property

Every control that derives from ItemsControl (including the ListBox) has an Items property that stores the collection of items represented by the control.

The Items property of an ItemsControl is also its content property.  This means that you can set the value of the Items property directly in XAML by specifying a list of child elements for the control that derives from ItemsControl.

For example, you can explicitly specify the child elements using property element syntax:

        <ListBox Margin="15" Width="250" Height="250">
            <ListBox.Items>
                <ListBoxItem Content="Thing 1"/>
                <ListBoxItem Content="Thing 2"/>
            </ListBox.Items>
        </ListBox>

Because the Items property is a content property, you can be more concise, doing the following:

        <ListBox Margin="15" Width="250" Height="250">
            <ListBoxItem Content="Thing 1"/>
            <ListBoxItem Content="Thing 2"/>
        </ListBox>