[This is preliminary documentation and is subject to change.]

Looks for visual tree ancestor of given DependencyObject of given type

Namespace: Tools.WindowsT.WPF
Assembly: Tools.Windows (in Tools.Windows.dll) Version: 1.5.3.38916 (1.5.3.38916)

Syntax

C#
public static TParent GetVisualAncestor<TParent>(
	this DependencyObject obj
)
where TParent : DependencyObject
Visual Basic
<ExtensionAttribute> _
Public Shared Function GetVisualAncestor(Of TParent As DependencyObject) ( _
	obj As DependencyObject _
) As TParent
Visual C++
[ExtensionAttribute]
public:
generic<typename TParent>
where TParent : DependencyObject
static TParent GetVisualAncestor(
	DependencyObject^ obj
)
F#
static member GetVisualAncestor : 
        obj:DependencyObject -> 'TParent  when 'TParent : DependencyObject
JScript
JScript does not support generic types or methods.

Parameters

obj
Type: System.Windows..::..DependencyObject
A DependencyObject to get ancestor of

Type Parameters

TParent
Type of ancestor to get

Return Value

Nearest ancestor of obj which of type TParent; null when such ancestor cannot be found.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DependencyObject. When you use instance method syntax to call this method, omit the first parameter. For more information, see or .

Remarks

This function uses [!:GetParent] to get parents of investigated DependencyObjects.

See Also

Collapse/expand Version History

1.5.3

  • (Nightly) This function is new in version 1.5.3