我正在尝试对此进行数据绑定ItemsControl
:
<ItemsControl ItemsSource="{Binding Path=Nodes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
通过使用它DataTemplate
,我试图将我的Node
元素单独定位在Canvas
正确的位置:
<DataTemplate DataType="{x:Type Model:EndNode}">
<Controls:EndNodeControl Canvas.Left="{Binding Path=XPos}" Canvas.Top="{Binding Path=YPos}" />
</DataTemplate>
但是,它没有按预期工作。我所有的节点元素都在同一位置相互叠加。关于如何做到这一点的任何建议?