Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Children (Panel)

Silverlight

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

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).

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.

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.

Canvas

InkPresenter

Grid (Silverlight 2)

StackPanel (Silverlight 2)

Community Additions

Show:
© 2015 Microsoft