TryFindChild Method
TryFindChild<T>(DependencyObject)
Returns the first child of the specified type found in the visual tree.
Declaration
public static T TryFindChild<T>(this DependencyObject parent)
where T : DependencyObject
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | parent | The parent element where the search is started. |
Returns
Type | Description |
---|---|
T | The first child of the specified type found in the visual tree, or null if no parent of the specified type is found. |
Type Parameters
Name | Description |
---|---|
T |
TryFindChild<T>(DependencyObject, String)
Returns the first child of the specified type and with the specified name found in the visual tree.
Declaration
public static T TryFindChild<T>(this DependencyObject parent, string childName)
where T : DependencyObject
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | parent | The parent element where the search is started. |
System.String | childName | The name of the child element to find, or an empty string or null to only look at the type. |
Returns
Type | Description |
---|---|
T | The first child that matches the specified type and child name, or null if no match is found. |
Type Parameters
Name | Description |
---|---|
T |