Bringing a floating window to the top

8 posts, 0 answers
  1. Michael
    Michael avatar
    15 posts
    Member since:
    Jul 2011

    Posted 04 Aug 2011 Link to this post

    I have multiple floating windows (RadPanes) that are visible, I want to ensure that a certain window is shown when an action is taken.

    Is there a method on the pane (or its group or container?) to make a window pop to the top of the z order?

    Thanks
  2. David
    David avatar
    9 posts
    Member since:
    Jul 2011

    Posted 07 Aug 2011 Link to this post

    I have the same question. Also, I'm having trouble even finding the Floating windows.. I try the following which does find docked windows, but does NOT find the floating windows. Help much appreciated!

    var 

    pane = this.FindName(paneName) as RadPane;

    (update...)
    I saw from another post in this forum how to do the find, but I still have the OP's issue about bringing the desired floating window to the front. I now find the pane using    var pane = DockingRoot.Panes.Where(p => p.Name == paneName).FirstOrDefault();

     

  3. DevCraft banner
  4. David
    David avatar
    9 posts
    Member since:
    Jul 2011

    Posted 07 Aug 2011 Link to this post

    Aha, I think I have this working now. It seems to handle both docked and floating panes ok

     

     

     

     

     

    public void ShowPaneForExistingWorkitem(int workitemId)
            {
                var paneName = "Pane__workitem " + workitemId.ToString();
                var pane = DockingRoot.Panes.Where(p => p.Name == paneName).FirstOrDefault();
      
                if (pane != null)
                {
                    if (pane.IsFloating)
                    {
                        var tw = pane.ParentOfType<ToolWindow>();
                        if (tw != null)
                        {
                            tw.BringToFront();
                            tw.Focus();
                        }
                    }
                    else
                    {
                        var parentPaneGroup = pane.Parent as RadPaneGroup;
                        if (parentPaneGroup != null)
                            parentPaneGroup.SelectedItem = pane;
                    }
                }
                else
                {
                    pane = new RadPane {Name = paneName, Title = paneName, CanFloat = true};
                    var workitemEditor = new PaneWorkitemEdit();
                    MainDockingPaneGroup.Items.Add(pane);
                    pane.Content = workitemEditor;
                    workitemEditor.workitemId = workitemId;
                }
            }
        }

  5. Michael
    Michael avatar
    15 posts
    Member since:
    Jul 2011

    Posted 08 Aug 2011 Link to this post

    Thanks David!   This seems to work for docked items too.

    I put this into a helper function.  You could obviously make it an extension method too.

    Cheers.

    public void BringPaneToTop(RadPane pane)
    {
      if (pane != null)
      {
        if (pane.IsFloating)
        {
          var tw = pane.ParentOfType<ToolWindow>();
          if (tw != null)
          {
            tw.BringToFront();
            tw.Focus();
          }
        }
        else
        {
          var parentPaneGroup = pane.Parent as RadPaneGroup;
          if (parentPaneGroup != null)
            parentPaneGroup.SelectedItem = pane;
        }
      }
    }


  6. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 10 Aug 2011 Link to this post

    Hello Everybody,

     What I would suggest you is to use the ActivePane API we added in the 2011 Q2 release. What you need to do is just to set the ActivePane to be the one you want to bring to the front.

    One more thing - ParentOfType<ToolWindow>() will not always help you to find the Window that hosts the pane (for example if the Pane is hidden). A better way to find it is to call the GetParentToolWindow extension method of the RadPane, RadPaneGroup and RadSplitContainer classes.

    Regards,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  7. Michael
    Michael avatar
    15 posts
    Member since:
    Jul 2011

    Posted 10 Aug 2011 Link to this post

    Thanks Miroslav,

    Good tip on the GetParentToolWindow() extension method.

    I've tried setting the ActivePane on the dock control, and it did not bring floating windows to the top.  It only worked if the panes were docked and/or pinned.  The workaround David proposed seemed to do the trick.

    Mike
  8. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 11 Aug 2011 Link to this post

    Hi Michael,

     It looks like a bug in the ActivePane functionality that we will be targeting. Once the fix is ready you will be able to remove the work-around.

    Greetings,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  9. Scott
    Scott avatar
    30 posts
    Member since:
    Aug 2011

    Posted 21 Oct 2011 Link to this post

    The floating RadPane may be a member of a group. E.g., float the first pane, float a second pane, doc the second onto the first.

    I took the proposed code, incorporated the moderator's suggestion, and added the highlighted code to get the following (complying with some of our coding style guidelines):

    private void BringPaneToTop(RadPane radPane)
    {
        if (radPane != null)
        {
            if (radPane.IsFloating)
            {
                ToolWindow toolWindow = radPane.GetParentToolWindow();
                if (toolWindow != null)
                {
                    toolWindow.BringToFront();
                    toolWindow.Focus();
                    RadPaneGroup parentRadPaneGroup = radPane.Parent as RadPaneGroup;
                    if (parentRadPaneGroup != null)
                    {
                        parentRadPaneGroup.SelectedItem = radPane;
                    }
                }
            }
            else
            {
                RadPaneGroup parentRadPaneGroup = radPane.Parent as RadPaneGroup;
                if (parentRadPaneGroup != null)
                {
                    parentRadPaneGroup.SelectedItem = radPane;
                }
            }
        }
Back to Top
DevCraft banner