In WPF, what is a TemplatedParent?

TemplatedParent refers to the Control instance that the template is being applied to. You can use TemplatedParent to bind to properties declared on that object (and its base classes).


In WPF, a template is what it uses to construct the tree of a type. WPF essentially makes a copy of the template when a new object of that type is created.

As a result, inside the template, if you want to refer to the new object, you use TemplatedParent for quick access. Otherwise, you'll have to use RelativeSource to walk the tree upwards to find the parent object.

Tags:

Wpf