0

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.

Max Young
  • 1,522
  • 1
  • 16
  • 42
  • 2
    I'd recommend adding some code and explain [what you have tried](http://mattgemmell.com/2008/12/08/what-have-you-tried/) and what issues you're facing. – ChiefTwoPencils Jan 27 '13 at 03:03
  • I added my code for my existing pane and I am trying to figure out how to add to it when I press a button. Problem is I don't even know where to begin. – Max Young Jan 27 '13 at 03:40

1 Answers1

9

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.

John Fairbanks
  • 1,342
  • 12
  • 16
  • Thank you, I am still using avalon dock because it has been pretty easy to use and still meets most of my needs. I could never figure out how to do this so I really appreciate it. – Max Young Aug 25 '15 at 14:27