Setting Canvas properties in an ItemsControl DataTemplate

Posted by atsjoo on Stack Overflow See other posts from Stack Overflow or by atsjoo
Published on 2009-08-12T10:22:41Z Indexed on 2010/05/17 12:20 UTC
Read the original article Hit count: 361

Filed under:
|
|

I'm trying to databind to this ItemsControl:

<ItemsControl ItemsSource="{Binding Path=Nodes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Canvas />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

By using this DataTemplate, I'm trying to individually position my Node elements correctly:

<DataTemplate DataType="{x:Type Model:EndNode}">
    <Controls:EndNodeControl Canvas.Left="{Binding Path=XPos}" Canvas.Top="{Binding Path=YPos}" />
</DataTemplate>

However, it's not working as expected. All my node elements are drawn on top of each other in the same position. Any suggestions on how to accomplish this?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#