[2.0] Create New Window via WPF Window inheritance

Oct 19, 2012 at 8:00 PM

Not sure if the title is exactly correct, but what I want to do is create a collection of WPF Windows using VS; I want these windows to inherit from an Avalon Type so that they are dockable in my main window.

I would like instances of these windows created on the fly via code after a user selects a menu option.  

I have been trying for the last few days to figure out how to do this but cannot find the type I should be inheriting from, or I am missing the proper configuration to make this happen.

Any assistance would be greatly appreciated!  Thanks, Tony

Dec 21, 2012 at 7:23 PM
Edited Dec 21, 2012 at 7:24 PM

I had put using Avalon Dock on hold for a few month hoping the 2.0 documentation would be updated by now.  It appears it has not and I am still faced with my original question (above) -- If anyone could help out I would appreciate it!  - Thanks!

Jan 2, 2013 at 12:20 PM


you can use System.Windows.Controls.UserControl to define your windows.

To add dockable contents to the DockingManager you have to create a LayoutDocument for each window and set the content property with your window.

MyWindow myWnd = new MyWindow();

LayoutDocument layoutDoc = new LayoutDocument();
layoutDoc.Title = "MyWindow";
layoutDoc.Content = myWnd;
layoutDoc.ContentId = "MyWindow";

var firstDocumentPane = _dockManager.Layout.Descendents().OfType<LayoutDocumentPane>().FirstOrDefault();

_dockManager.Layout.ActiveContent = layoutDoc;



Jan 4, 2013 at 9:17 PM

Awesome, thanks!  Just what I needed.

Just so other people know to get this working you need to add: using AvalonDock.Layout;