Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

LogicalTreeHelper.FindLogicalNode Method

Attempts to find and return an object that has the specified name. The search starts from the specified object and continues into subnodes of the logical tree.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

public static DependencyObject FindLogicalNode(
	DependencyObject logicalTreeNode,
	string elementName


Type: System.Windows.DependencyObject
The object to start searching from. This object must be either a FrameworkElement or a FrameworkContentElement.
Type: System.String
The name of the object to find.

Return Value

Type: System.Windows.DependencyObject
The object with the matching name, if one is found; returns null if no matching name was found in the logical tree.

The methods FrameworkContentElement.FindName and FrameworkElement.FindName are superficially similar to FindLogicalNode, but operate by different logic:

  • The search direction for FindLogicalNode is toward child objects (down the tree); the search direction for the FindName methods is towards parent objects (up the tree).

  • The FindName methods are governed by the concept of a XAML namescope. Using FindName you are guaranteed that only one object of that name exists, because XAML namescopes enforce uniqueness. In contrast, FindLogicalNode ignores XAML namescope and might cross XAML namescope boundaries during the search. As such, there is no guarantee of uniqueness of the elementName name once boundaries are crossed. For more information about XAML namescopes, see WPF XAML Namescopes.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
© 2018 Microsoft