Gets the parent object of the calling object.

retval = object.GetParent()

Type: object

A reference to the parent object if successful; otherwise, returns null.

The only objects that can contain UIElement children are Canvas and InkPresenter. The UIElement types that can be child objects of Canvas and InkPresenter are listed in the "Applies To" section of this topic.

Calling the GetParent method on Canvas or on any other object that is at the XAML root will return null. To retrieve the hosting plug-in instance, always use the GetHost method.

Path can have child elements, but these are geometries instead of UIElement objects. Therefore, you cannot call GetParent on a Path's child elements. As a workaround, you should always name the Path so that it can be accessed without having to walk the tree.

Community Additions