I'm binding an ItemsControl with Canvas as ItemsPanelTemplate to an ObservableCollection.
I want to make the items draggable using the DraggableExtender as posted in http://stackoverflow.com/questions/294220/dragging-an-image-in-wpf (I don't want to use transforms - I need to use the Canvas Left and Top properties)
It's defined as :
<ItemsControl ItemsSource="{Binding Path=Nodes}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas IsItemsHost="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Views:NodeView DataContext="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Utilities:DraggableExtender.CanDrag" Value="True" />
<Setter Property="Canvas.Left" Value="{Binding Path=X}" />
<Setter Property="Canvas.Top" Value="{Binding Path=Y}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
The DraggableExtender needs the parent of the element to be the Canvas, but the parent of my element (contentpresenter) is null, so the dragging doesn't work.
So the obvious question is - what am I doing wrong ?