Visual.GetVisualChild(Int32) Visual.GetVisualChild(Int32) Visual.GetVisualChild(Int32) Visual.GetVisualChild(Int32) Method

定義

傳回父 Visual 中所指定的 VisualCollectionReturns the specified Visual in the parent VisualCollection.

protected:
 virtual System::Windows::Media::Visual ^ GetVisualChild(int index);
protected virtual System.Windows.Media.Visual GetVisualChild (int index);
abstract member GetVisualChild : int -> System.Windows.Media.Visual
override this.GetVisualChild : int -> System.Windows.Media.Visual
Protected Overridable Function GetVisualChild (index As Integer) As Visual

參數

index
Int32 Int32 Int32 Int32

VisualCollection 中視覺物件的索引。The index of the visual object in the VisualCollection.

傳回

VisualCollection 中指定之 index 值處的子物件。The child in the VisualCollection at the specified index value.

範例

下列範例會定義的覆寫實的作GetVisualChildThe following example defines an overridden implementation of GetVisualChild.

// Provide a required override for the GetVisualChild method.
protected override Visual GetVisualChild(int index)
{
    if (index < 0 || index >= _children.Count)
    {
        throw new ArgumentOutOfRangeException();
    }

    return _children[index];
}
' Provide a required override for the GetVisualChild method.
Protected Overrides Function GetVisualChild(ByVal index As Integer) As Visual
	If index < 0 OrElse index >= _children.Count Then
		Throw New ArgumentOutOfRangeException()
	End If

	Return _children(index)
End Function

備註

根據預設,Visual沒有子系。By default, a Visual has no children. 因此,預設實作永遠會擲回ArgumentOutOfRangeExceptionTherefore, the default implementation always throws an ArgumentOutOfRangeException.

給繼承者的注意事項

衍生自類別Visual必須覆寫這個方法,以及VisualChildrenCount屬性正確列舉視覺化樹狀結構。A class that derives from Visual must override this method, and also the VisualChildrenCount property, for the visual tree to be enumerated correctly.

適用於