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

Dynamically add and remove particular Pane/PaneGroup?

1 Answer 271 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 05 Jul 2014, 04:43 PM
I have RadDocking control with one split container and 4 RadPaneGroups each with single Pane in it. I need to implement possibility to hide and add third and fourth panes. I have done that via 
    SplitContainer.Items.Add(MyPaneGroup3);
and
    SplitContainer.Items.Remove(MyPaneGroup3);
This is working until user rearranges pane groups. After that both these calls do nothing even if PaneGroup is moved back to its initial location (at least visually). Is there a way to avoid this thing and be able to remove and add PaneGroup after user rearranged them?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Polya
Telerik team
answered on 07 Jul 2014, 11:17 AM
Hi Dmitry,

When we reorder RadPaneGroups in a RadSplitContainer the following actions are performed:
1) A new RadPaneGroup is created and the Items(RadPanes) of the original RadPaneGroup are placed inside the new one.
2) The new RadPaneGroup is placed in a ToolWindow.
3) The original RadPaneGroup is removed from the Items Collection of the RadSplitContainer.
4) When placing/docking the ToolWindow inside the SplitContainer, again, a new RadPaneGroup is created and the Items of the ToolWindow RadPaneGroup are placed inside the new RadPaneGroup.
5) The ToolWindow is closed.

Based on that, after a reorder of a RadPaneGroup the RadSplitContainer contains a copy of that group and not the original, so this line SplitContainer.Items.Remove(MyPaneGroup3); won't remove anything because MyPaneGroup3 is no longer in the Items of the SplitContainer.

I suggest, for example, modifying the remove logic to exclude RadPaneGroups based on information of their child RadPanes. This way we will not relate on a concrete instance of a RadPaneGroup(that will be lost when reordering it), but on its content ( which will be the same ). Here is a code snippet that removes the first RadPaneGroup from the SplitContainer that has a RadPane with header "Pane Group 3":

IEnumerable<RadPaneGroup> realPanes = this.SplitContainer.Items.OfType<RadPaneGroup>().Where(pg => pg.EnumeratePanes().Any(p => p.Header.ToString().Equals("Pane Group 3")));
if (realPanes.Any())
{
    this.SplitContainer.Items.Remove(realPanes.First());
}

Hopefully this helps and is applicable for your scenario.

Regards,
Polya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Docking
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Polya
Telerik team
Share this question
or