GetChildrenCount Method

VisualTreeHelper.GetChildrenCount Method (DependencyObject)


Returns the number of children that the specified visual object contains.

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

public static int GetChildrenCount(
	DependencyObject reference


Type: System.Windows.DependencyObject

The parent visual that is referenced as a DependencyObject.

Return Value

Type: System.Int32

The number of child visuals that the parent visual contains.

Use the GetChild method to retrieve a specified child of a parent visual.

The value of reference can represent either a Visual or Visual3D object, which is why the common base type DependencyObject is used here as a parameter type.

Legacy Code Example

The following example shows how to enumerate all the descendants of a visual object. This is a technique you might use if you are interested in serializing all the rendering information of a visual object hierarchy or are performing analysis or alternative rendering.

Code snippet is not found. Confirm that the code snippet name 'VisualsOverview' is correct.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft