[This is preliminary documentation and is subject to change.]
Searches for ancestor of given WPF object of given type in logical tree
Namespace: Tools.WindowsT.WPFAssembly: Tools.Windows (in Tools.Windows.dll) Version: 1.5.3.38916 (1.5.3.38916)
Syntax
| C# |
|---|
public static TAncestor FindLogicalAncestor<TAncestor>( this DependencyObject obj ) where TAncestor : DependencyObject |
| Visual Basic |
|---|
<ExtensionAttribute> _ Public Shared Function FindLogicalAncestor(Of TAncestor As DependencyObject) ( _ obj As DependencyObject _ ) As TAncestor |
| Visual C++ |
|---|
[ExtensionAttribute] public: generic<typename TAncestor> where TAncestor : DependencyObject static TAncestor FindLogicalAncestor( DependencyObject^ obj ) |
| F# |
|---|
static member FindLogicalAncestor : obj:DependencyObject -> 'TAncestor when 'TAncestor : DependencyObject |
| JScript |
|---|
|
Parameters
- obj
- Type: System.Windows..::..DependencyObject
Object to find ancestor of
Type Parameters
- TAncestor
- Type of ancestor to find. This type must be or derive from DependencyObject.
Return Value
The closest ancestor of object obj which's type is TAncestor. Null where there is no such ancestor.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
Remarks
This function uses GetParent(ContentElement) to walk visual tree upwards from obj.
If TAncestor is Window (not type derived from Window) GetWindow(DependencyObject) is used instead.
Exceptions
| Exception | Condition |
|---|---|
| System..::..ArgumentNullException | obj is null |
See Also
Version History
1.5.3
- This function is new in version 1.5.3