我正在尝试与此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>
但是,它没有按预期运行。我所有的节点元素都在同一位置相互绘制。关于如何做到这一点的任何建议?