Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
640
TabGroupPane + PaneCloseAction.RemovePane issue
posted

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:

  1. Click  "Add Content TabGroupPane #1" => ContentPane "1.1" is added
  2. Click  "Add Content TabGroupPane #2" => ContentPane "2.1" is added
  3. Click  "Output TabGroupPanes Properties", you get the following output:
    Parent TabGroupPane #1 Infragistics.Windows.DockManager.SplitPane
    Parent TabGroupPane #2 Infragistics.Windows.DockManager.SplitPane
  4. Close the ContentPanes "1.1" and "2.1"
  5. Click "Output TabGroupPanes Properties", you get the following output:
    Parent TabGroupPane #1 Infragistics.Windows.DockManager.SplitPane
    Parent TabGroupPane #2
  6. Click  "Add Content TabGroupPane #1" => ContentPane "1.2" is added
  7. Click  "Add Content TabGroupPane #2" => No ContentPane is added

Notice:

  • In step 5. the Parent property is set to null (same happened to me with other attached property of other application)
  • In method private void btnAddContentTabGroup2_Click(object sender, RoutedEventArgs e) if you comment the line //newContentPane.CloseAction = PaneCloseAction.RemovePane; =>
    - In step 5. you get Parent TabGroupPane #2 Infragistics.Windows.DockManager.SplitPane
    - In step 7. you get ContentPane "2.2" is added
  • If you add a Name to the 2nd TabGroupPane (ex: "MyTabGroupPane2") =>
    - In step 5. you get Parent TabGroupPane #2 Infragistics.Windows.DockManager.SplitPane
    - In step 7. you get ContentPane "2.2" is added

Workaround for now is to have the Name property set, but I would like to hear other thoughts.

Thanks,
Claudio. 

Parents
No Data
Reply
  • 54937
    Offline posted

    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).

Children
No Data