Children (Panel)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the collection of child elements on the object. This property can be set in XAML through implicit collection syntax.

<object ...>
  oneOrMoreUIElements
</object>
value = object.Children

XAML Values

Value

Description

oneOrMoreUIElements

One or more object elements that derive from UIElement. These can be one or more of the following: Border (Silverlight 2), Canvas, Ellipse, Glyphs, Grid (Silverlight 2), Image, InkPresenter, Line, MediaElement, PasswordBox (Silverlight 2), Path, Polygon, Polyline, Popup (Silverlight 2), Rectangle, Shape, StackPanel (Silverlight 2), TextBlock, TextBox, (Silverlight 2).

Property Value

Type: VisualCollection

The collection of child UIElement objects.

This property is read-only. You can use implicit collection syntax in XAML or methods of the VisualCollection object in script to add items or otherwise change the existing collection, but you cannot replace the collection with a different object. The default value is an empty VisualCollection collection.

Managed Equivalent

Children

Remarks

The XAML syntax for Children is an example of an implicit collection syntax. In this case, because the property is read-only, neither the explicit property element tag <Canvas.Children> nor the object element for the explicit collection <VisualCollection> is permitted by the XAML parser. The implicit collection syntax of placing one or more child elements as direct child elements of a <Canvas> object element is the only permitted XAML syntax.

In scripting, you can get the value of Children and retain it for later operations against the collection, but you cannot set the Children property directly. Instead, you typically use CreateFromXaml to create a single node at a time, and then add that node to the VisualCollection object by using the syntax object.Children.Add(xamlNode).

Objects that are added to the Children collection are rendered immediately.

InkPresenter is a derived class of Canvas and inherits its Children property. The Children for an InkPresenter render on the InkPresenter surface just as they do on a Canvas. For more information about how to mix stroke and child element content, see the "Remarks" section in the InkPresenter reference topic.

For Silverlight 2 JavaScript API, Children is also a property of Grid and StackPanel.

Applies To

Canvas

InkPresenter

Grid (Silverlight 2)

StackPanel (Silverlight 2)

See Also

Reference