【发布时间】:2010-11-18 22:02:44
【问题描述】:
我正在尝试将数据绑定到这个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>
但是,它没有按预期工作。我所有的节点元素都在同一位置相互叠加。关于如何实现这一点的任何建议?
【问题讨论】:
标签: c# wpf xaml canvas itemscontrol