Partager via


ContextNode.SubNodes, propriété

Mise à jour : November 2007

Obtient les enfants directs de l'objet ContextNode.

Espace de noms :  System.Windows.Ink
Assembly :  IAWinFX (dans IAWinFX.dll)

Syntaxe

'Déclaration
Public ReadOnly Property SubNodes As ContextNodeCollection
'Utilisation
Dim instance As ContextNode
Dim value As ContextNodeCollection

value = instance.SubNodes
public ContextNodeCollection SubNodes { get; }
public:
property ContextNodeCollection^ SubNodes {
    ContextNodeCollection^ get ();
}
/** @property */
public ContextNodeCollection get_SubNodes()
public function get SubNodes () : ContextNodeCollection

Valeur de propriété

Type : System.Windows.Ink.ContextNodeCollection
Enfants directs de l'objet ContextNode.

Notes

Ne retourne pas tous les descendants, mais uniquement les enfants directs.

Exemples

Cet exemple est une méthode qui parcourt de manière récursive une arborescence d'objets ContextNode. Il utilise la propriété SubNodes et remplit un [System.Windows.Controls.TreeView] en ajoutant des objets TreeViewItem. Il affecte alors la méthode GetRecognizedString à leurs propriétés Header.

Private Shared Sub WalkTree(ByVal parentContextNode As ContextNode, ByVal parentTreeNode As TreeViewItem) 

    parentTreeNode.IsExpanded = True

    For Each theContextSubnode As ContextNode In parentContextNode.SubNodes
        Dim newTreeNode As New TreeViewItem()
        newTreeNode.Header = theContextSubnode.ToString()

        If TypeOf theContextSubnode Is InkWordNode Then
            newTreeNode.Header += ": " + CType(theContextSubnode, InkWordNode).GetRecognizedString()
        ElseIf TypeOf theContextSubnode Is InkDrawingNode Then
            newTreeNode.Header += ": " + CType(theContextSubnode, InkDrawingNode).GetShapeName()
        End If

        ' If the context node is confirmed, add a note to the
        ' tree view item.
        If (theContextSubnode.IsConfirmed(ConfirmationType.NodeTypeAndProperties)) Then

            newTreeNode.Header += " Confirmed."
        End If


        ' Add the context node as a tag of the tree view item and
        ' add the new tree view item to the parent node.
        newTreeNode.Tag = theContextSubnode
        parentTreeNode.Items.Add(newTreeNode)

        WalkTree(theContextSubnode, newTreeNode)
    Next theContextSubnode

End Sub 'WalkTree
private static void WalkTree(ContextNode parentContextNode, TreeViewItem parentTreeNode)
{
    // Expand the current TreeViewItem.
    parentTreeNode.IsExpanded = true;

    foreach (ContextNode theContextSubnode
        in parentContextNode.SubNodes)
    {
        TreeViewItem newTreeNode = new TreeViewItem();
        newTreeNode.Header = theContextSubnode.ToString();

        if (theContextSubnode is InkWordNode)
        {
            newTreeNode.Header += ": " +
                ((InkWordNode)theContextSubnode).GetRecognizedString();
        }
        else if (theContextSubnode is InkDrawingNode)
        {
            newTreeNode.Header += ": " +
                ((InkDrawingNode)theContextSubnode).GetShapeName();
        }

        // If the context node is confirmed, add a note to the
        // tree view item.
        if (theContextSubnode.IsConfirmed(ConfirmationType.NodeTypeAndProperties))
        {
            newTreeNode.Header += " Confirmed.";
        }

        // Add the context node as a tag of the tree view item and
        // add the new tree view item to the parent node.
        newTreeNode.Tag = theContextSubnode;
        parentTreeNode.Items.Add(newTreeNode);

        WalkTree(theContextSubnode, newTreeNode);
    }
}

Plateformes

Windows Vista

Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Informations de version

.NET Framework

Pris en charge dans : 3.0

Voir aussi

Référence

ContextNode, classe

Membres ContextNode

System.Windows.Ink, espace de noms

ContextNode.ParentNode