FrameworkElement.VisualChildrenCount 속성

정의

이 요소 내 시각적 자식 요소의 수를 가져옵니다.

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

속성 값

이 요소에 대한 시각적 자식 요소의 수입니다.

예제

다음 예제에서는 사용자 지정 표시기가 여러 시각적 자식에 대해 유지 관리하는 에 VisualCollection 의해 선언된 값을 사용하고 및 GetVisualChild의 재정의 VisualChildrenCount 를 통해 이러한 값을 보고하는 방법을 보여 줍니다.

// To store and manage the adorner's visual children.
VisualCollection visualChildren;
' To store and manage the adorner's visual children.
Private visualChildren As VisualCollection
// Override the VisualChildrenCount and GetVisualChild properties to interface with 
// the adorner's visual collection.
protected override int VisualChildrenCount { get { return visualChildren.Count; } }
protected override Visual GetVisualChild(int index) { return visualChildren[index]; }
' Override the VisualChildrenCount and GetVisualChild properties to interface with 
' the adorner's visual collection.
Protected Overrides ReadOnly Property VisualChildrenCount() As Integer
    Get
        Return visualChildren.Count
    End Get
End Property
Protected Overrides Function GetVisualChild(ByVal index As Integer) As Visual
    Return visualChildren(index)
End Function

설명

VisualChildrenCount 구현은 FrameworkElement 항상 0 또는 1을 반환합니다. 1을 초과할 수 있는 시각적 자식 컬렉션을 유지 관리하는 클래스는 이 속성과 GetVisualChild를 모두 재정의해야 합니다.

이 속성은 일반적으로 레이아웃 재정의를 구현하기 위해 현재 자식 컬렉션의 상한을 결정하는 데 사용됩니다(MeasureOverride, ArrangeOverride).

상속자 참고

클래스가 자식 요소 컬렉션에서 둘 이상의 시각적 자식 자식 을 지원하는 경우 이 속성을 재정의하여 해당 컬렉션의 요소 수를 반환합니다. 컬렉션 개체 자체가 개수를 반환하는 경우에도 이 작업을 수행해야 합니다. WPF 프레임워크 수준의 요소 레이아웃 논리는 모든 요소가 속성을 통해 VisualChildrenCount 유효한 개수를 반환한다고 가정합니다.

적용 대상