I managed to do something like this:
- Set image as background
- Place a transparent
ItemsControl on top of it - Set
ItemsControl.ItemsPanel to Canvas - wrote handlers for drag and drop operations
Code snippet:
<ItemsControl x:Name="overlayItemsControl" Background="Transparent" ItemsSource="{Binding Path=Blocks}" Width="{Binding ElementName=imageControl, Path=Width}" Height="{Binding ElementName=imageControl, Path=Height}" ItemContainerStyle="{StaticResource rectStyle}" PreviewMouseMove="ItemsControl_PreviewMouseMove" PreviewMouseDown="ItemsControl_PreviewMouseDown" PreviewMouseUp="ItemsControl_PreviewMouseUp" PreviewKeyDown="ItemsControl_PreviewKeyDown"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas IsItemsHost="True" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> .... </ItemsControl>
source share