After a lot of debugging I think I've found an issue when setting a ContentPane.CloseAction =PaneCloseAction.RemovePane and having a TabGroupPane without the Name property set.
Let me illustrate it with a sample
XAML
I have 2 TabGroupPanes. Only difference is that 1 have its Name property set and the other one doesn't.
<igDock:XamDockManager x:Name="dockManager" Grid.Row="0" Grid.Column="0"> <igDock:DocumentContentHost> <igDock:SplitPane Name="SplitPane1"> <igDock:TabGroupPane Name="TabGroupPane1" /> </igDock:SplitPane> <igDock:SplitPane Name="SplitPane2"> <igDock:TabGroupPane /> </igDock:SplitPane> </igDock:DocumentContentHost> </igDock:XamDockManager>
I also have 3 buttons to add ContentPane to each tab and to Ouput the TabGroupPane properties:
<Button Name="btnOutputProperties" Content="Output TabGroupPanes Properties" Grid.Row="1" Click="btnOutputProperties_Click" ></Button> <Button Name="btnAddContentTabGroup1" Content="Add Content TabGroupPane #1" Grid.Row="2" Click="btnAddContentTabGroup1_Click"></Button> <Button Name="btnAddContentTabGroup2" Content="Add Content TabGroupPane #2" Grid.Row="3" Click="btnAddContentTabGroup2_Click"></Button>
Code Behind
TabGroupPane tabGroupPane2; int iTab1 = 0; int iTab2 = 0; public Window1() { InitializeComponent(); tabGroupPane2 = (TabGroupPane)SplitPane2.Panes[0]; } private void btnAddContentTabGroup1_Click(object sender, RoutedEventArgs e) { RichTextBox rtb = new RichTextBox(); ContentPane newContentPane = new ContentPane(); newContentPane.Content = rtb; newContentPane.CloseAction = PaneCloseAction.RemovePane; iTab1 += 1; newContentPane.Header = "1." + iTab1; TabGroupPane1.Items.Add(newContentPane); } private void btnAddContentTabGroup2_Click(object sender, RoutedEventArgs e) { RichTextBox rtb = new RichTextBox(); ContentPane newContentPane = new ContentPane(); newContentPane.Content = rtb; newContentPane.CloseAction = PaneCloseAction.RemovePane; iTab2 += 1; newContentPane.Header = "2." + iTab2; tabGroupPane2.Items.Add(newContentPane); } private void btnOutputProperties_Click(object sender, RoutedEventArgs e) { Console.WriteLine("Parent TabGroupPane #1 " + TabGroupPane1.Parent); Console.WriteLine("Parent TabGroupPane #2 " + tabGroupPane2.Parent); }
To see the issue Run the application and:
Notice:
Workaround for now is to have the Name property set, but I would like to hear other thoughts.
Thanks,Claudio.
This is actually intended behavior. When a SplitPane/TabGrouppane is no longer needed (e.g. you remove/move all the contentpanes elsewhere) the dockmanager will remove the splitpane/tabgroup. This is done to remove the overhead of having unneeded/unused panes remaining in the visual/logical tree. A pane will not be removed if its Name property has been set on the assumption that you will be using that pane again (plus since VS would have created a member variable for it).