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
790
How to remove contentpane from UnpinnedTabArea items
posted

Hi,

I'm trying to re-create content panes from code as part of different default views requirement. But I'm encountering an error whenever I unpin a content pane and trying to add the same to a split pane in  another view.

Error:

Specified element is already the logical child of another element. Disconnect it first.

I tried to disconnect it in various ways unsuccessfully.

contentPane.ExecuteCommand(ContentPaneCommands.TogglePinnedState);

when I use the below code. I get a different error: Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.

((UnpinnedTabArea)contentPane.Parent).Items.Clear();

Could you please help me resolving the issue asap.

Thanks,

Parents
No Data
Reply
  • 54937
    Verified Answer
    Offline posted

    This sounds like what I described here. Try setting the CloseAction of the ContentPane to RemovePane (if it's not already set), execute the ContentPaneCommands.Close command and then reset the CloseAction (if you had to change it). In this way all the internal references to the ContentPane should be removed.

Children
No Data