Count Property
Gets the number of items contained in the collection.
XAML |
Cannot be used in XAML.
|
Scripting |
value = object.Count
|
Property Value
integer
The number of items contained in the collection.
This property is read-only. The default value is 0 for an initially empty collection.
Remarks
For several common Silverlight elements, you can get the relevant collection and enumerate the child items of a parent object by accessing the "Children" collection of the parent object (Canvas.Children, GeometryGroup.Children, Storyboard.Children, TransformGroup.Children). Other commonly used collection properties are Path.Data, TextBlock.Inlines, and LinearGradientBrush.GradientStops.
Note Using the Count property with an object that does not support a collection will raise a Silverlight runtime error.
Examples
The following JavaScript example shows how to use the Count property to enumerate the children of a parent Canvas object:
JavaScript |
---|
function getChildren(parent, index) { // Enumerate the children of the Canvas object. for (i = 0; i < parent.children.count; i++) { var child = parent.children.getItem(i); // Display the index and type of the child object. alert(i + ": " + child.toString()); } } |
Applies To
Collection, GeometryCollection, GradientStopCollection, Inlines, PathFigureCollection, PathSegmentCollection, StrokeCollection, StylusPointCollection, TransformCollection, TriggerCollection, VisualCollection