Visual.VisualChildrenCount Visual.VisualChildrenCount Visual.VisualChildrenCount Visual.VisualChildrenCount Property

定义

获取 Visual 的子元素数量。Gets the number of child elements for the Visual.

protected:
 virtual property int VisualChildrenCount { int get(); };
protected virtual int VisualChildrenCount { get; }
member this.VisualChildrenCount : int
Protected Overridable ReadOnly Property VisualChildrenCount As Integer

属性值

子元素的数量。The number of child elements.

示例

下面的示例定义的VisualChildrenCount重写实现。The following example defines an overridden implementation of VisualChildrenCount.

// Provide a required override for the VisualChildrenCount property.
protected override int VisualChildrenCount
{
    get { return _children.Count; }
}
' Provide a required override for the VisualChildrenCount property.
Protected Overrides ReadOnly Property VisualChildrenCount() As Integer
    Get
        Return _children.Count
    End Get
End Property

注解

默认情况下, Visual没有任何子级。By default, a Visual has no children. 因此, 默认实现始终返回0。Therefore, the default implementation always returns 0.

继承者说明

Visual派生的类必须重写此属性和GetVisualChild(Int32)方法, 以便正确枚举可视化树。A class that derives from Visual must override this property, and also the GetVisualChild(Int32) method, for the visual tree to be enumerated correctly.

适用于