Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

FrameworkElement.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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public DependencyObject TemplatedParent { get; }
/** @property */
public DependencyObject get_TemplatedParent ()

public function get TemplatedParent () : DependencyObject

You cannot use this property in XAML.

Property Value

The element whose FrameworkTemplate VisualTree caused this element to be created. This value is frequently a null reference (Nothing in Visual Basic); 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 a null reference (Nothing in Visual Basic) 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 a null reference (Nothing in Visual Basic) 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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2014 Microsoft. All rights reserved.