In WPF, what is a TemplatedParent?

前端 未结 3 2073
小鲜肉
小鲜肉 2020-12-29 20:48

I\'m trying to understand RelativeSource binding but I can\'t find a definition for TemplatedParent. MSDN says:

\"Gets a static value that is used to

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 21:30

    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.

提交回复
热议问题