TryFindParent Method
TryFindParent<T>(DependencyObject, Boolean)
Gets first parent element of the specified type. Which tree the parent is retrieved from depends on the parameters.
Declaration
public static T TryFindParent<T>(this DependencyObject child, bool searchCompleteVisualTree = false)
where T : DependencyObject
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | child | The child to get parent for. |
System.Boolean | searchCompleteVisualTree | If true the parent in the visual tree is returned, if false the parent may be retrieved from another tree depending on the child type. |
Returns
Type | Description |
---|---|
T | The first parent element of the specified type, and depending on the parameters its retrieved from either visual tree, logical tree or a tree not strictly speaking either the logical tree or the visual tree. null is returned if no parent of the specified type is found. |
Type Parameters
Name | Description |
---|---|
T |