TabDragDemo.png

You can use DragDropLiteEventProcessor to provide drag and drop support for Tab in TabControl, to re-arrange it, provided that your TabControl and TabItem uses MVVM implementation.

1. Add the event processor to the tab control
<uc:TabControlEx>
  <bc:UIEventAdapter.Processors>
                    <bc:DragDropLiteEventProcessor EnableMouse="True" EnableTouch="True" 
                                               EnableDrag="True" EnableDrop="True" />                
                </bc:UIEventAdapter.Processors>
</uc:TabControlEx>


2. Implement IDraggable, ISelectable, ISupportDropHelper in the TabItem's ViewModel, and assign DropHelper to an instance of TabDropHelper<T>.

TabDropHelper implements ISupportDrop which calls TabControlViewModel's MoveTab() method when ISupportDrop.Drop() is called, or if dragging item is not an TabViewModel, it calls change selected tab to the drag over tab.

e.g TabViewModel in Test_TabDragDemo.

3. Implemment ISupportDragHelper and ITabControlViewModel<TabViewModel> in the TabControl (Container)'s ViewModel, and assign DragHelper to an instance of TabControlDragHelper<T>.

TabControlDragHelper implements ISupportDrag to return the ViewModel of selected tab when ISupportDrag.GetDraggables() is called.

e.g TabControlViewModel in Test_TabDragDemo.



Last edited Oct 17, 2014 at 5:47 PM by lycj, version 6

Comments

No comments yet.