我是使用ControlTemplate
的新手。我正在写我的第一个控件,但我有(在我看来)一个非常奇怪的问题。TemplateBinding不能使用.NET框架对象
任何依赖属性,我让TemplateBinding
工作,但是从.NET Framework对象即一个ContentControl
的Content
财产或ItemsControl
的Items
财产的任何属性没有得到在运行时填充。
我相信我失去了一些东西...只是它是什么,我不知道......
代码的下面是一个例子:
类是目前十分简单:
public class Title : ContentControl
{
}
和模板是:
<Style TargetType="{x:Type UI:Title}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type UI:Title}">
<TextBlock Text="{TemplateBinding Content}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
基础ContentControl
CL ass是位于System.Windows.Controls.Control命名空间中的.NET类。
感谢,
亚当
您可以添加代码片段以显示哪些不起作用? – Bubblewrap 2009-08-21 14:34:57
对不起。我现在加了一个。 谢谢。 – Adam 2009-08-21 14:51:56