Telerik blogs

For the Q3 2009 release, we have added a few important new features to the RadDock. The first of these features is the ability to set the tab strip alignment and/or visibility on DocumentTabStrip and ToolTabStrip instances. The second feature we have added is the ability to implement your own manual drag and drop behavior.

Tab Alignment and Visibility

New TabStrip PropertiesWhen working with ToolTabStrips and DocumentTabStrips in the Q3 release, you will notice that we have added two new properties. The first of these properties, TabStripAlignment, allows you to set the alignment of tabs within their parent TabStrip. The second of these properties, TabStripVisible, allows you to specify whether or not the tabs should be visible. You can see these features in action in the RadControls for WinForms demo application under RadDock -> TabStrip Properties.




Manual Drag and Drop Behavior

Drag and drop automation is now possible with the RadDock. The DragDropService of the RadDock now contains a property, DragDropBehavior, that you can set to auto or manual. Setting this property to manual allows you to implement your own custom drag and drop behavior based on the events provided by the DragDropService object.

Using a manual implementation of this service, I've created a simple class that allows for it's users to animate the dragging of a ToolWindow through one line of code.

private void btnDragDrop_Click(object sender, EventArgs e)
    _radDockAutomation.DoDragDrop(toolWindow1, DockPosition.Fill, toolWindow2);


The class, RadDockAutomation, takes a RadDock in its constructor. In calling the DoDragDrop method, you must specify a ToolWindow to drag and drop, the way in which to dock it, and the ToolWindow to dock it inside of or relative to. Upon calling this method, the DragDropBehavior of the DragDropService is set to manual, two events are subscribed to, and a timer is started.

public void DoDragDrop(DockWindow dragDropDockWindow, DockPosition toDockPosition, DockWindow toDockWindow)
    // Setup the DragDropService for custom behavior
    _ddService.DragDropBehavior = DragDropBehavior.Manual;
    _ddService.PreviewHitTest += new DragDropHitTestEventHandler(_ddService_PreviewHitTest);
    _ddService.Stopped += new EventHandler(_ddService_Stopped);
    // Set the toPosition and DockWindow
    _toDockPosition = toDockPosition;
    _toDockWindow = toDockWindow;
    // Set the initial position of the window being dragged
    _prevPosition = dragDropDockWindow.Parent.RectangleToScreen(dragDropDockWindow.Bounds).Location;
    _radDock.FloatWindow(dragDropDockWindow, new Rectangle(this._prevPosition, DragDropService.DefaultFloatingSize));
    // Start the drag
    _ddService.Start(dragDropDockWindow.FloatingParent, this._prevPosition);


The timer is responsible for moving the specified DockWindow within its tick event. The PerformDrag method being called calculates the next position the ToolWindow should be moved to on a point by point basis.

void _timer_Tick(object sender, EventArgs e)
    _ddService.PerformDrag(GetNextPoint(_toDockPosition, _toDockWindow));


The PreviewHitTest event of the DragDropService is responsible for detecting when the DockWindow being moved has reached the specified location. Once it has reached the specified location, the service is stopped and the drag drop automation is completed.

void _ddService_PreviewHitTest(object sender, DragDropHitTestEventArgs e)
    if ((e.DropTarget == _toDockWindow.DockTabStrip)
        && (e.HitTest.DockPosition != null 
        && e.HitTest.DockPosition == _toDockPosition))


Click here to download the source code used in this post.


Comments are disabled in preview mode.