【发布时间】:2013-12-03 10:13:18
【问题描述】:
考虑一个自定义控件,在ResourceDictionary 中通过Style 定义ControlTemplate:
<Style TargetType="{x:Type local:MyControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyControl}">
....
在该模板的某些地方,我有一个 ContentControl,我想将其内容设置为 TemplatedParent 本身。
如果我将它绑定到 TemplatedParent 上的一个属性,效果会很好:
Content="{TemplateBinding LayoutMode}"
但是有没有办法将它绑定到TemplatedParent 本身?如果没有,是否有任何解决方法?
【问题讨论】:
标签: c# wpf custom-controls controltemplate