Search code examples
c#wpfwindowdockavalondock

AvalonDock dock a window


I am trying to convert my app in WPF to work with AvalonDock. I have a few windows(about 10) and main form that has DockingManager. I would like to put those windows inside that DockingManager. I've tried this:

<ad:DockingManager x:Name="MainWindow">
    <ad:DocumentPane x:Name="Windows" />
</ad:DockingManager>

FormDocumentSearch formDocumentSearch = new FormDocumentSearch(dc, this); //create window
DockableContent dct = new DockableContent() { Title = "Window" }; //create DockableContent
dct.Content = formDocumentSearch; //put the window in the DockableContent
Windows.Items.Add(dct); 

This gives me the following error: Window must be the root of the tree. Cannot add Window as a child of Visual..

What can I do? How can I put a Window or how to modify them so that I can still use the designer and have them in AvalonDock?


Solution

  • I dont think you can add a window in side another window. Try to change window as Page.

    change

    <Window ... >
    
    ...
    
    </Window>
    

    to

    <Page ... >
    
    ...
    
    </Page>
    

    For all windows you wanted to add as child.