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

How to programatically check floating panes

6 Answers 492 Views
Docking
This is a migrated thread and some comments may be shown as answers.
RoxanaC
Top achievements
Rank 1
RoxanaC asked on 23 Aug 2010, 12:32 PM
Hello!
Is there a way to iterate over a RadDocking control  and check which RadPanes are floating, ans eventually make them docked also from code?

Thank you!
Roxana

6 Answers, 1 is accepted

Sort by
0
RoxanaC
Top achievements
Rank 1
answered on 23 Aug 2010, 12:57 PM
OK, you can check the floating state using IsFloating ( if I know the panes i use this from the start, but I would still like to iterate somehow through the RadDocking ) but how can I set the RadPane position in document host or in one of the available DockState -s ?
0
George
Telerik team
answered on 25 Aug 2010, 12:56 PM
Hello RoxanaC,

Could you describe what you want to achieve in details? The DocumentHost is arranged in the RadDocking layout according to all other SplitContainers in the RadDocking control.  

I will be glad to assist you further.

Regards,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
RoxanaC
Top achievements
Rank 1
answered on 25 Aug 2010, 02:15 PM
Hello George!
again :)

As you already know, the floating panes are getting me a headache...
Sometimes, in my application I am changing the RadDocking component visibility to Collapsed, in order to switch between the application modes. Now, if some of my RadPanes are floating their visibility does not change to Collapsed in the same time with their RadDocking parent, but they remain visible - which is not the desired behavior for me (they all should get Collapsed or Visible no mater the floating state).
Now I am thinking about a workaround, before making my RadDocking Collapsed I want to check if there are floating RadPanes and to dock them in a default position so they will all disappear with their parent.
Anyway this looks like a bug for me, maybe I should open an issue about that.
What is your opinion on this?

Best regards!
Roxana
0
George
Telerik team
answered on 25 Aug 2010, 05:01 PM
Hello,

Thank you for getting back to me.

First of all, let me explain something about the  RadDocking control, its structure and how does it works. It will shed some light.

The RadDocking control arranges its components via DocumentHost, RadSplitContainers, RadPaneGroups, RadPanes, RadDocumentPane and ToolWindows. However, I suggest you refer to our online documentation, if you haven't yet, where everything is explained in details.

RadPanes are placed in the RadPaneGroups and they represents only the small TabItems (you can refer to the attached picture for details). When a RadPane is selected, its content is shown in the RadPaneGroup that contains this RadPane. RadPaneGroups are placed in RadSplitContainer.

When you drag(make floating) a pane, this pane goes out from the group. A new ToolWindow is generated, a brand new RadSplitContainer and RadPaneGroup are generated also.They go into this ToolWindow and the pane goes into this brand new RadPaneGroup. This means that the pane goes out of the RadDocking layout. When you make RadDocking collapsed, it doesn't affect the pane because it is not placed in the RadDocking control anymore.

To collapsed the ToolWindows with the RadDocking, I suggest you to handled PaneStateChange event of RadDocking.Then you can find the ToolWindows that contains the floating panes in the event handler and keep a list of their reference. Once you have a list with the ToolWindows, you can collapse them (set their Visibility property to Collapsed) in the same moment that you collapse the docking control.

Here is the code to get the ToolWindow using this PaneStageChange event handler:

private void RadDocking_PaneStateChange(objectsender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadPane pane = e.Source asRadPane;
            if(pane != null && pane.IsFloating)
            {
                ToolWindow toolWindow = pane.ParentOfType<ToolWindow>();
                if(toolWindow == null)
                {
                    toolWindow = (((pane.Parent asRadPaneGroup).Parent asRadSplitContainer).Parent) asToolWindow;
                    if(toolWindow != null)
                    {
                        // you got the toolWindow
                    }
                }
                else
                {
                    // you got the toolWindow
                }
            }
        }

Note, that there is a bug in the framework when you make RadPane floating via the ContextMenu - ParentOfType<ToolWindow> returns null in these circumstances. That's why you could get the ToolWindow using the Parent property. 

I hope this helps! Please do not hesitate to contact us if you require any further information. I am glad to assist you further.


Regards,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
1
Accepted
George
Telerik team
answered on 26 Aug 2010, 12:33 PM
Hello,

Updating:

The code I gave you in the previous post is for Silverlight version of RadDocking, here is the code for WPF version of RadDocking:

private void dock_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadDocking dock = e.Source as RadDocking;
            List<RadPane> list = dock.Panes.Where(p => p.IsFloating).ToList();
            if (dock != null && list.Count > 0)
            {
                foreach (var item in list)
                {
                    ToolWindow toolWindow = item.ParentOfType<ToolWindow>();
                    if (toolWindow == null)
                    {
                        toolWindow = (((item.Parent as RadPaneGroup).Parent as RadSplitContainer).Parent) as ToolWindow;
                        if (toolWindow != null)
                        {
                          // you got the toolWindow
                        }
                    }
                    else
                    {
                        // you got the toolWindow
                    }
                }
            }
        }

Sorry for the mistake.

Greetings,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
RoxanaC
Top achievements
Rank 1
answered on 26 Aug 2010, 02:31 PM
Thank you for assistance George!
I knew this things about RadDocking, as I already read the documentation, but for me it makes more sense for the ToolWindow to be bound with the RadDocking control by things like resources, visibility & stuff. Even when you save a docking layout, in that XML result you can see that the floating split containers are belonging to the RadDocking...

Anyway, the previous code was OK (with a minor change - RanPane pane = e.OriginalSource as RadPane)
Thank you for help!
Regards!
Roxana

Tags
Docking
Asked by
RoxanaC
Top achievements
Rank 1
Answers by
RoxanaC
Top achievements
Rank 1
George
Telerik team
Share this question
or