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
50
Problem with loading controls after we close and open an existing pane
posted

In my silverlight application, I have two controls

1. Control1

2. Control2

These two controls are to be displayed in the xamDockManager in a Tabbed Group pane. 

Tabbed group pane is inside the SplitPane which is placed Left to the xamDockmanager.

I can add the control in any order, and user can also close any control before adding the second one. Now after I add the first control (Control1) to the xamDockmanager.

The code behind for MainPage is:

 

public partial class MainPage : UserControl
       {
              SplitPane _spLeft = null;
              TabGroupPane _tgpLeft = null;
              public MainPage()
              {
                     InitializeComponent();
                     _spLeft = new SplitPane();
                     _tgpLeft = new TabGroupPane();
                     _spLeft.Location = XamDockLocation.Left;
                     _spLeft.Orientation = Orientation.Vertical;
                     _tgpLeft.Location = XamDockLocation.Left;
                     _tgpLeft.Width = 300;
                     _tgpLeft.Height = 400;
              }
 
              private void button1_Click(object sender, RoutedEventArgs e)
              {
                     AddPaneInDockManager("Control1", new Control1());
              }
              private void button2_Click(object sender, RoutedEventArgs e)
              {
                     AddPaneInDockManager("Control2", new Control2());
              }
              private void AddPaneInDockManager(string paneHeader, UserControl control)
              {
                     ContentPane cp = new ContentPane();
                     cp.Header = paneHeader;
                     cp.AllowClose = true;
                     cp.AllowDocking = true;
                     cp.AllowDockingFloating = false;
                     cp.CloseButtonVisibility = Visibility.Visible;
                     cp.WindowPositionMenuVisibility = System.Windows.Visibility.Visible;
                     cp.AllowDockingInTabGroupPane = true;
                     cp.Content = control;
                     if (!_tgpLeft.Panes.Contains(cp))
                           _tgpLeft.Panes.Add(cp);
                     if (!_spLeft.Panes.Contains(_tgpLeft))
                           _spLeft.Panes.Add(_tgpLeft);
                     if (!xamdocmanager.Panes.Contains(_spLeft))
                           xamdocmanager.Panes.Add(_spLeft);
              }
       }

User  has two options There are two cases

1. If user adds the Control2 to the tabbed group pane after adding the Control1, there is no issue.

2. If user closes the Control1 and then adds the Control2 using the same code, following error is displayed: "Element is already the child of another element". I am not sure why this error is displayed. Please help. Because in our case, user can close a control and add another control to the tabbed group.

I have also noticed that when the user closes the control1 before adding the control 2, xdockmanager doesnot have the splitpane in any of the four collections:

1. Panes

2. ClosedPanes

3. FloatingPanes

4. UnPinnedPanes

ClosedPanes collection has the ContentPane which is (Control1).

Where exactly the Splitpane gone. I guess error is actually of splitpane being already added. Problem is I am not able to find the SplitPane that I already added to the xDockManager control.

  • 1158
    Suggested Answer
    Offline posted

    ... wrong post ... sorry

  • 138253
    Offline posted

    Hello,

     

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.

  • 138253
    Offline posted

    Hello,

    Thank you for your post. I have been looking into it and was able to reproduce your behavior, so I created a sample project for you with a workaround for this issue. Basically I get the Parent of the SplitPane and remove the SplitPane from it, this way there isn’t any exception any more. Please let me know if this helps you or you need further assistance on this matter.

    Looking forward for your reply.

    SilverlightApplication1.zip