0
我创建了一个自定义的控制,但我不能一个属性绑定到这样的内容:当我创建的控制自定义控件绑定属性
<Style TargetType="control:Pie">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="control:Pie">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentControl Content="{Binding Path=Test}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
而且在我的控制
public string Test
{
get { return (string)GetValue(TestProperty); }
set { SetValue(TestProperty, value); }
}
public static readonly DependencyProperty TestProperty =
DependencyProperty.Register(
"Test",
typeof(string),
typeof(Pie),
new PropertyMetadata(null));
在Test属性中设置一个字符串,但在视图中没有任何内容出现...
哦,是的,谢谢! – Peekyou