Questa documentazione è stata archiviata e non viene gestita.

Classe VisualTreeHelper

Contains static methods that are useful for performing common tasks with nodes in a visual tree. This class cannot be inherited.

Spazio dei nomi: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)
Spazio dei nomi XML:

public static class VisualTreeHelper
public final class VisualTreeHelper
public final class VisualTreeHelper
Non è possibile utilizzare questa classe gestita in XAML.

Nodes in the visual tree may be either Visual or Visual3D objects. Methods that are specific to a type of visual object are typed as either Visual or Visual3D. However, some methods in the VisualTreeHelper class can accept a DependencyObject value that represents either type of visual object.

In most cases, the logical tree is a more useful representation of the elements in a WPF application. Although you do not modify the logical tree directly, this view of the application is useful for understanding property inheritance and event routing. Unlike the visual tree, the logical tree can represent non-visual data objects, such as ListItem. For more information on the logical tree, see Element Tree.

The following example shows how to enumerate all the descendants of a visual object, which is a technique you might want to use if you were interested in serializing all the rendering information of a visual object hierarchy.

// Enumerate all the descendants of the visual object.
static public void EnumVisual(Visual myVisual)
    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
        // Retrieve child visual at specified index value.
        Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);

        // Do processing of the child visual object.

        // Enumerate children of the child visual object.


I membri statici pubblici (Shared in Visual Basic) di questo tipo sono validi per le operazioni multithreading. I membri di istanza non sono garantiti come thread safe.

Microsoft .NET Framework 3.0 è supportato in Windows Vista, Microsoft Windows XP SP2 e Windows Server 2003 SP1.

.NET Framework

Supportato in: