Prevent DockTabControl Floating outside parent control

Posted by: vinothkumar.r2210 on 20 May 2020, 9:26 pm EST

  • Posted 20 May 2020, 9:26 pm EST

    Hi,
    How to prevent docktabcontrol floating outside parent control. Please find the attached image.

    Also when floating completed and not docked then the docktabcontrol not returned to its original position.

    Thanks and Regards,
    Vinoth Kumar Ravi
  • Marked as Answer

    Replied 22 May 2020, 7:10 am EST

    Hi Vinoth,

    I would suggest you to try using C1DragDropManager and handle its DragLeave event. Below is sample code snippet for same.
    C1DragDropManager dd = new C1DragDropManager();
    foreach (UIElement e in _docktab1.Items)
    {
    dd.RegisterDragSource(e, DragDropEffect.Move, ModifierKeys.None);
    }
    foreach (UIElement e in dockControl.Items)
    {
    dd.RegisterDropTarget(e, true);
    }
    dd.RegisterDragSource(_docktab1, DragDropEffect.Move, ModifierKeys.None);
    dd.DragLeave += Dd_DragLeave;
    private void Dd_DragLeave(object source, DragDropEventArgs e)
    {
    var dragSource = e.DragSource as C1.WPF.Docking.C1DockTabControl;
    if(dragSource!=null)
    {
    var parent = dragSource.Parent as C1.WPF.Docking.C1DockControl;
    if (parent!=null)
    {
    if(parent.IsMouseCaptureWithin ==false && parent.IsMouseDirectlyOver == false )
    {
    e.Effect = DragDropEffect.None;
    }
    }
    }
    }
    Regards,
    Ruchir
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels