Visual.VisualChildrenCount Property

Definition

Gets the number of child elements for the Visual.

C#
protected virtual int VisualChildrenCount { get; }

Property Value

The number of child elements.

Examples

The following example defines an overridden implementation of VisualChildrenCount.

C#
// Provide a required override for the VisualChildrenCount property.
protected override int VisualChildrenCount
{
    get { return _children.Count; }
}

Remarks

By default, a Visual has no children. Therefore, the default implementation always returns 0.

Notes to Inheritors

A class that derives from Visual must override this property, and also the GetVisualChild(Int32) method, for the visual tree to be enumerated correctly.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9