Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

FrameworkContentElement.TemplatedParent Property

Gets a reference to the template parent of this element. This property is not relevant if the element was not created through a template.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
public DependencyObject TemplatedParent { get; }

Property Value

Type: System.Windows.DependencyObject
The element whose FrameworkTemplate VisualTree caused this element to be created. This value is frequently null; see Remarks.

Templates are actually shared objects, where the contents of the template are created only once. Therefore, if you obtain an object reference to an element that came from a template, you may find that the apparent logical tree does not reach to the page root. In order to connect such a template reference to the page's logical tree, you should get the TemplatedParent value and continue to navigate that element tree as desired.

TemplatedParent will frequently be null for common objects, because if you have obtained an object reference from out of a page in your application through typical means, that element probably was not created from a template. Cases where TemplatedParent might not be null would include operations such as hit-testing, event handling for certain low-level input events, or working with enumerators, which may have returned elements that came from templates.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.