カスタムコントロールを作成しましたが、次のようにプロパティをコンテンツにバインドできません:
<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プロパティに文字列が設定されますが、ビューに何も表示されません...