Visual.GetVisualChild(Int32) Metodo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce l’oggetto Visual specificato nell’oggetto VisualCollection padre.
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
Indice del nuovo oggetto visivo nell’oggetto VisualCollection.
L’elemento figlio nell’oggetto VisualCollection al valore index
specificato.
Nell'esempio seguente viene definita un'implementazione sottoposta a override di 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
Per impostazione predefinita, un oggetto Visual non ha figli. Pertanto, l'implementazione predefinita genera sempre un'eccezione ArgumentOutOfRangeException.
Una classe che deriva da Visual deve eseguire l'override di questo metodo e anche della VisualChildrenCount proprietà affinché l'albero visivo venga enumerato correttamente.
Prodotto | Versioni |
---|---|
.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, 10 |
Feedback su .NET
.NET è un progetto open source. Seleziona un collegamento per fornire feedback: