我正在尝试将数据绑定到这个ItemsControl
:
<ItemsControl ItemsSource="{Binding Path=Nodes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
通过使用这个 DataTemplate
,我试图正确地在 Canvas
上单独定位我的 Node
元素:
<DataTemplate DataType="{x:Type Model:EndNode}">
<Controls:EndNodeControl Canvas.Left="{Binding Path=XPos}" Canvas.Top="{Binding Path=YPos}" />
</DataTemplate>
然而,它并没有按预期工作。所有节点元素都在相同的位置上重叠绘制。有什么建议可以实现这一点吗?