FrameworkElement.Parent FrameworkElement.Parent FrameworkElement.Parent FrameworkElement.Parent Property


Gets the parent object of this FrameworkElement in the object tree.

public : DependencyObject Parent { get; }
DependencyObject Parent();
public DependencyObject Parent { get; }
Public ReadOnly Property Parent As DependencyObject
Property Value

The parent object of this object in the object tree.


Parent can be null if an object was instantiated, but is not attached to an object that eventually connects to a page object root. In the default Windows Runtime classes, the parent of a FrameworkElement can also be expected to be a FrameworkElement subclass if it's not null. But custom classes might introduce a content model where this assumption is not true.

Note that the parent of an object can change if you adjust your app's object tree at run time. You typically should get the parent object value immediately before you need it for other operations, and should not rely on the value past this point.

Parent is read-only. You can change the parent of an object in most cases, but is done through manipulation of collections of the existing parent and a new parent. For example, you can add or remove from Children of a Panel.

Generally, you can conceive of the object tree of a UWP app using C++, C#, or Visual Basic as representing a nested series of objects and property values. If a given object has one or more contained children held in some type of Content or Children property, then Parent describes the inverse of that relationship. Most of the time, Parent is the same value as returned by VisualTreeHelper API. However, there may be cases where Parent reports a different parent than VisualTreeHelper does.

See Also