public RVector3 Vector3D
{
get { return (RVector3)GetValue(Vector3DProperty); }
set { SetValue(Vector3DProperty, value); }
}
public static readonly DependencyProperty Vector3DProperty =
DependencyProperty.Register(
"Vector3D",
typeof(RVector3),
typeof(ExpanderVector3),
new PropertyMetadata(new RVector3())
);
<ControlTemplate TargetType="{x:Type ctrls:ExpanderVector3}">
<Border
Margin="10"
CornerRadius="50">
<ui:CardExpander
IsExpanded="{TemplateBinding IsExpanded}"
>
<ui:CardExpander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ui:TextBlock
Grid.Row="0" Grid.Column="0"
FontSize="16"
FontTypography="Body"
Text="{TemplateBinding Title}"/>
<ui:TextBlock
Grid.Row="1" Grid.Column="0"
FontSize="12"
Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}"
Text="{TemplateBinding Description}"/>
</Grid>
</ui:CardExpander.Header>
<StackPanel
Margin="24 0 24 0">
<ui:CardControl
Header="{Binding Vector3D.Name,
RelativeSource={RelativeSource AncestorType=model:RVector3}, Mode=OneWay}"
>
</ui:CardControl>
</StackPanel>
</ui:CardExpander>
</Border>
</ControlTemplate>
안녕하세요 윈폼개발자에서 WPF로 넘어온 개발자입니다.
Dependency Property로 선언된 Vector3D의 속성값중 Name을 바인딩하려고 하는데 그림과 같이 에러가 발생합니다. UserControl로 하면 되는데 ControlTemplate로 구현하면 되지 않습니다.