Visual.VisualChildrenCount 屬性

定義

取得 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

屬性值

Int32

子項目數量。The number of child elements.

範例

下列範例會定義的覆寫執行 VisualChildrenCountThe 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.

適用於