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

Bringing a floating window to the top

7 Answers 163 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 04 Aug 2011, 11:56 PM
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

7 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 07 Aug 2011, 10:35 AM
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();

 

0
David
Top achievements
Rank 1
answered on 07 Aug 2011, 11:18 AM
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;
            }
        }
    }

0
Michael
Top achievements
Rank 1
answered on 08 Aug 2011, 03:59 PM
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;
    }
  }
}


0
Miroslav Nedyalkov
Telerik team
answered on 10 Aug 2011, 12:12 PM
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 >>

0
Michael
Top achievements
Rank 1
answered on 10 Aug 2011, 07:22 PM
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
0
Miroslav Nedyalkov
Telerik team
answered on 11 Aug 2011, 09:54 AM
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 >>

0
Scott
Top achievements
Rank 1
answered on 21 Oct 2011, 07:13 PM
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;
            }
        }
    }
Tags
Docking
Asked by
Michael
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Scott
Top achievements
Rank 1
Share this question
or