Detect Floating Pane Drop

2 posts, 0 answers
  1. Zugbo
    Zugbo avatar
    1 posts
    Member since:
    Jun 2011

    Posted 16 Sep 2011 Link to this post

    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.
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 21 Sep 2011 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top