DiagramingDemo.png

CanvasDragEventProcessor allow you to drag multiple items from an canvas to different position, by chaning Top and Left property, an adorner with the selected items in lower opacity is shown when dragging.

How to use?

View
CanvasDragEventProcessor works on canvas only, the Canvas.Left/Top attached property of subItems should be bound to DataContext.Left/Top property.

e.g. MainWindow in DiagramingDemo

You have to enable the processor by using the following code:
<bc:UIEventAdapter.Processors>
    <bc:CanvasDragEventProcessor />
    <bc:MultiSelectEventProcessor EnableMultiSelect="True" 
                                UnselectAllCommand="{Binding Commands.UnselectAllCommand}" />
    <bc:CanvasResizeEventProcessor />
</bc:UIEventAdapter.Processors>

MultiSelect in this case is done by HitTest, if you want better performance you may create a canvas that support IChildInfo interface.



ViewModel

Your container view model (Canvas.DataContext) should implement ISupportDrag or ISupportDragHelper, thus can return selected items.

Your item view model should implement IPositionAware, IDraggable and ISelectable interface.

CanvasDragEventProcessor only update your IPositionAware.Left/Top when drag is completed.

Implementation
Please see source.

Last edited Oct 17, 2014 at 5:16 PM by lycj, version 9

Comments

No comments yet.