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
Key
M11
M12
M21
M22
Tag
Uri
X1
X2
Y1
Y2
Expand Minimize

Count

Silverlight

Gets the number of items contained in a collection.

value = object.Count

Type: integer

The number of items contained in a collection.

This property is read-only. The default value is 0 for an initially empty collection.

Each collection type potentially implements this differently. The most common equivalent for Silverlight programming is PresentationFrameworkCollection<T>.Count.

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.

NoteNote:

Using the Count property with an object that does not support a collection will raise a Silverlight run-time error.

The following JavaScript example shows how to use the Count property to enumerate the children of a parent Canvas object.

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());
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft