Question

I am working with avalon dock v2 and all I am trying to do is have it so when I hit a button it adds another pane to my layout.

This is my existing pane but I don't know the syntax to add another pane to it when I press a button.

avalonDock:DockingManager x:Name="dockingManager">
                <avalonDock:LayoutRoot>
                    <avalonDock:LayoutPanel Orientation="Horizontal">
                        <avalonDock:LayoutDocumentPaneGroup >
                            <avalonDock:LayoutDocumentPane x:Name="mainDocumentPaneGroup">

                            </avalonDock:LayoutDocumentPane>
                        </avalonDock:LayoutDocumentPaneGroup>
                      </avalonDock:LayoutPanel>
                </avalonDock:LayoutRoot>
  </avalonDock:DockingManager>

Here is what I put inside the button.

 DockPanel CNPCTab = new DockPanel() { };
        CNPCTab.Name = "CNPCTab";

        mainDocumentPaneGroup.

I don't really see any methods that would allow me to add the pane I initialized to group I initialized in the xaml.

Was it helpful?

Solution

I don't know if you still need an answer to this or not, but I needed it as well and couldn't really find a good answer anywhere so I'm provding it here. You need to create a LayoutArchorable, set its Content to your UserControl, and then call the AddToLayout method on the LayoutArchorable to get it to add itself. In my case I wanted the new window to start as Floating so the user could decide where to drop it, but you still have to assign it somewhere before it can float.

    LayoutAnchorable la = new LayoutAnchorable { Title = "New Window", FloatingHeight = 400, FloatingWidth = 500, Content = new YourUserControl() };
    la.AddToLayout(dockingManager, AnchorableShowStrategy.Right);
    la.Float();

In this example, I named the DockingManager in the XAML so I could access it from the code behind.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top