LogicalTreeHelper.FindLogicalNode Method

Attempts to find and return an element node that has the specified name. The search starts from the specified element and continues into subnodes.

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

public static DependencyObject FindLogicalNode(
	DependencyObject logicalTreeNode,
	string elementName
)
You cannot use methods in XAML.

Parameters

logicalTreeNode
Type: System.Windows.DependencyObject

The element to start searching from. This object must be either a FrameworkElement or FrameworkContentElement type.

elementName
Type: System.String

The name of the element node to find.

Return Value

Type: System.Windows.DependencyObject
The element with the matching name, if one is found; returns null if no matching name was found in the active namescope.

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 elements; the search direction for the FindName methods is toward parent elements.

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft