This is a migrated thread and some comments may be shown as answers.

Detect Floating Pane Drop

1 Answer 87 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Zugbo
Top achievements
Rank 1
Zugbo asked on 16 Sep 2011, 09:12 PM
I'm trying to use the RadDocking for its tabs that can be peeled off into new windows- ideally when this is done I'll have something like Chrome or IE's tabs. I know it's not a perfect match, but I don't know of any other controls that work better for this. 

My specific problem, is that when I drag a tab out of its tab strip, it floats immediately, and I don't know how to catch an event for "dropping" it- letting go of the mouse in a non-docking region. I'm hoping that I can detect the drop, rather than the pick up, because I need to build a new window around floating tabs, but I also need to make sure not to "window in" tabs in transit to other docking areas.

For reference, my current (non-working) code is below. Its problem is that I never get a chance to move tabs to existing dockin gregions, it always makes the new window.

private void radDocking1_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
      if (e.OriginalSource.GetType() == typeof(RadPane))
      {
        RadPane Pane = (RadPane)e.OriginalSource;
        if (Pane.IsFloating)
        {
          MainWindow newWindow = new MainWindow();
          Pane.RemoveFromParent();
          newWindow.radPaneGroup1.AddItem(Pane, DockPosition.Center);
          newWindow.Show();
        }      
      }
    }

Also, if you can think of a better way to make a draggable tab interface than using RadDocking, please let me know.

1 Answer, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 21 Sep 2011, 12:12 PM
Hello Zugbo,

Instead of getting the Pane you can get the ToolWindow in which actually the Pane is put in when it is floating. You can do that for example by implementing this method:

private ToolWindow GetToolWindow(RadPane pane)
        {
            ToolWindow window = pane.ParentOfType<ToolWindow>();
            if (window == null)
            {
                window = (((pane.Parent as RadPaneGroup).Parent as RadSplitContainer).Parent) as ToolWindow;
            }
            return window;
        }

After that in the PaneStateChanged event get the ToolWindow and hook to its LayoutUpdateEnded event which should fire exactly when the drop is over:

private void radDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
       {
            if (e.OriginalSource.GetType() == typeof(RadPane))
               {
                 RadPane Pane = (RadPane)e.OriginalSource;
                 if (Pane != null && Pane.IsFloating)
                 {
                     ToolWindow toolWindow = GetToolWindow(pane);
                     toolWindow.LayoutChangeEnded += new EventHandler(toolWindow_LayoutChangeEnded);
                   }
               
     }
void toolWindow_LayoutChangeEnded(object sender, EventArgs e)
       {
           //Do some work here
       }

Hope this helps.

Greetings,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Docking
Asked by
Zugbo
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Share this question
or