TreeWalker.GetFirstChild Metodo
Definizione
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.
Recupera il primo elemento figlio dell'oggetto specificato AutomationElement.
Overload
| Nome | Descrizione |
|---|---|
| GetFirstChild(AutomationElement) |
Recupera il primo elemento figlio dell'oggetto specificato AutomationElement. |
| GetFirstChild(AutomationElement, CacheRequest) |
Recupera il primo elemento figlio delle proprietà e memorizza nella cache le proprietà e i modelli specificati AutomationElement . |
Commenti
Un AutomationElement oggetto può avere elementi figlio aggiuntivi che non corrispondono alla condizione di visualizzazione corrente e pertanto non vengono restituiti durante l'esplorazione dell'albero degli elementi.
La struttura dell'albero AutomationElement cambia man mano che cambiano gli elementi dell'interfaccia utente visibile sul desktop. Non è garantito che un elemento restituito come primo elemento figlio venga restituito come primo elemento figlio nei passaggi successivi.
GetFirstChild(AutomationElement)
Recupera il primo elemento figlio dell'oggetto specificato AutomationElement.
public:
System::Windows::Automation::AutomationElement ^ GetFirstChild(System::Windows::Automation::AutomationElement ^ element);
public System.Windows.Automation.AutomationElement GetFirstChild(System.Windows.Automation.AutomationElement element);
member this.GetFirstChild : System.Windows.Automation.AutomationElement -> System.Windows.Automation.AutomationElement
Public Function GetFirstChild (element As AutomationElement) As AutomationElement
Parametri
- element
- AutomationElement
Elemento da cui recuperare il primo elemento figlio.
Valori restituiti
Primo elemento figlio o riferimento Null (Nothing in Visual Basic) se tale elemento non è presente.
Esempio
Nell'esempio seguente viene illustrato GetFirstChild l'uso di per costruire una visualizzazione albero di elementi in un sottoalbero.
/// <summary>
/// Walks the UI Automation tree and adds the control type of each element it finds
/// in the control view to a TreeView.
/// </summary>
/// <param name="rootElement">The root of the search on this iteration.</param>
/// <param name="treeNode">The node in the TreeView for this iteration.</param>
/// <remarks>
/// This is a recursive function that maps out the structure of the subtree beginning at the
/// UI Automation element passed in as rootElement on the first call. This could be, for example,
/// an application window.
/// CAUTION: Do not pass in AutomationElement.RootElement. Attempting to map out the entire subtree of
/// the desktop could take a very long time and even lead to a stack overflow.
/// </remarks>
private void WalkControlElements(AutomationElement rootElement, TreeNode treeNode)
{
// Conditions for the basic views of the subtree (content, control, and raw)
// are available as fields of TreeWalker, and one of these is used in the
// following code.
AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(rootElement);
while (elementNode != null)
{
TreeNode childTreeNode = treeNode.Nodes.Add(elementNode.Current.ControlType.LocalizedControlType);
WalkControlElements(elementNode, childTreeNode);
elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
}
}
''' <summary>
''' Walks the UI Automation tree and adds the control type of each element it finds
''' in the control view to a TreeView.
''' </summary>
''' <param name="rootElement">The root of the search on this iteration.</param>
''' <param name="treeNode">The node in the TreeView for this iteration.</param>
''' <remarks>
''' This is a recursive function that maps out the structure of the subtree beginning at the
''' UI Automation element passed in as rootElement on the first call. This could be, for example,
''' an application window.
''' CAUTION: Do not pass in AutomationElement.RootElement. Attempting to map out the entire subtree of
''' the desktop could take a very long time and even lead to a stack overflow.
''' </remarks>
Private Sub WalkControlElements(ByVal rootElement As AutomationElement, ByVal treeNode As TreeNode)
' Conditions for the basic views of the subtree (content, control, and raw)
' are available as fields of TreeWalker, and one of these is used in the
' following code.
Dim elementNode As AutomationElement = TreeWalker.ControlViewWalker.GetFirstChild(rootElement)
While (elementNode IsNot Nothing)
Dim childTreeNode As TreeNode = treeNode.Nodes.Add(elementNode.Current.ControlType.LocalizedControlType)
WalkControlElements(elementNode, childTreeNode)
elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode)
End While
End Sub
Commenti
Un AutomationElement oggetto può avere elementi figlio aggiuntivi che non corrispondono alla condizione di visualizzazione corrente e pertanto non vengono restituiti durante l'esplorazione dell'albero degli elementi.
La struttura dell'albero AutomationElement cambia man mano che cambiano gli elementi dell'interfaccia utente visibile sul desktop. Non è garantito che un elemento restituito come primo elemento figlio venga restituito come primo elemento figlio nei passaggi successivi.
Vedi anche
- Panoramica dell'albero di automazione dell'interfaccia utente
- Spostarsi tra gli elementi di automazione interfaccia utente con TreeWalker
- Obtaining Automazione interfaccia utente Elements
Si applica a
GetFirstChild(AutomationElement, CacheRequest)
Recupera il primo elemento figlio delle proprietà e memorizza nella cache le proprietà e i modelli specificati AutomationElement .
public:
System::Windows::Automation::AutomationElement ^ GetFirstChild(System::Windows::Automation::AutomationElement ^ element, System::Windows::Automation::CacheRequest ^ request);
public System.Windows.Automation.AutomationElement GetFirstChild(System.Windows.Automation.AutomationElement element, System.Windows.Automation.CacheRequest request);
member this.GetFirstChild : System.Windows.Automation.AutomationElement * System.Windows.Automation.CacheRequest -> System.Windows.Automation.AutomationElement
Public Function GetFirstChild (element As AutomationElement, request As CacheRequest) As AutomationElement
Parametri
- element
- AutomationElement
Elemento da cui recuperare il primo elemento figlio.
- request
- CacheRequest
Oggetto richiesta cache che specifica proprietà e modelli nell'oggetto restituito AutomationElement nella cache.
Valori restituiti
Primo elemento figlio o riferimento Null (Nothing in Visual Basic) se tale elemento non è presente.
Commenti
Un AutomationElement oggetto può avere elementi figlio aggiuntivi che non corrispondono alla condizione di visualizzazione corrente e pertanto non vengono restituiti durante l'esplorazione dell'albero degli elementi.
La struttura dell'albero AutomationElement cambia man mano che cambiano gli elementi dell'interfaccia utente visibile sul desktop. Non è garantito che un elemento restituito come primo elemento figlio venga restituito come primo elemento figlio nei passaggi successivi.
Vedi anche
- Panoramica dell'albero di automazione dell'interfaccia utente
- Spostarsi tra gli elementi di automazione interfaccia utente con TreeWalker
- Obtaining Automazione interfaccia utente Elements