DockableContent start as dock center?

May 26, 2010 at 12:13 AM
Edited May 26, 2010 at 12:19 AM

I have a DockableContent window that I want to start as filling the entire screen.  I see I can use "Show( Dock.Left )" for example if I wanted to force a dock to the top, bottom, left or right, but I can't figure out how I would start this docked center.  Surely I'm missing something simple?  I did a search for "center", "dock center", "fill" etc and couldn't find anything obvious.

Also how do I get two dockableContent windows to be in the same DockablePane?  If I do "Show( Dock.Left )" it just puts them next to each other, but doesn't put them in the same pane.

May 27, 2010 at 6:00 PM

Does anyone have a cached link to the tutorial?  I think that would help a lot.

Right now, I'm trying to figure out how to add a dockableContent programatically to a specific dockablePane.  All the examples I'm finding do this straight in the xaml which doesn't work for me.

May 27, 2010 at 6:07 PM

Hi,

a DockablePane is an ItemsControl, so you should be able to add a DockableContent to it using a code like this:

var dockContent = new DockableContent() { Title = "My content", Name="MyContentName" };

dockPane.Items.Add(dockContent);

This code will work with next version too (1.3).

Anyway as a general rule, avoid to mantain references to dockablepanes because user can move/close them. Instead consider methods like DockingManager.Show() or better with the new version (1.3)

DockableContent.Show()

Ado

 

May 27, 2010 at 6:26 PM
Edited May 27, 2010 at 6:29 PM

thanks for the response!

In this app, users will be opening and closing tools regularly.  I want all tool like items to go to a certain pane by default.  If I just use "DockingManger.Show()" I find that I can't control where tools pop up enough.  A good example is in Visual Studio 9, if you close the "Class View" then open it again, it will show up next to the solution Explorer where it should be.  Likewise, when you open a project in visual studio, the solution explorer is on the left the toolbox is on the right, and the document is in the center.  I want to be able to control at least that initial layout.  I guess I could search for the DockablePane, and if that doesn't exist, search for a like-minded control, and if none are found, resort to spawning it where ever (DockingManager.Show()).  Is that how you would suggest doing it, or is there a better way? 

 

 

May 27, 2010 at 6:41 PM
Yes,
your solution can work, just traverse the docking manager content to find the right pane you need and add the content to it.
Anyway just for your info new version (1.3) handles cases you exposed better: for example when user closes a content, new version "remember" the position and when she shows it again AvalonDock redock the content to the correct position.
Regarding the initial layout consider to use DockingManager.SaveLayout()/RestoreLayout(). You could save to xml an initial layout and restore it when your app starts up.
Of course your way will continue to work,
Ado

Sent: Thursday, May 27, 2010 7:26 PM
Subject: Re: DockableContent start as dock center? [AvalonDock:213841]

From: SpaceCowboy850

thanks for the response!

In this app, users will be opening and closing tools regularly. I want all tool like items to go to a certain pane by default. If I just use "DockingManger.Show()" I find that I can't control where tools pop up. A good example is in Visual Studio 9, if you close the "Class View" then open it again, it will show up next to the solution Explorer where it should be. Likewise, when you open a project in visual studio, the solution explorer is on the left the toolbox is on the right, and the document is in the center. I want to be able to control at least that initial layout. I guess I could search for the DockablePane, and if that doesn't exist, search for a like-minded control, and if none are found, resort to spawning it where ever (DockingManager.Show()). Is that how you would suggest doing it, or is there a better way?

May 27, 2010 at 10:38 PM

So if you are working on this panel memory for 1.3, here are a few thoughts:

It would be nice to have a way to control how panels are recreated in the DockingManager if they all go away and be able to dictate where items go.  It would nearly be nice to be able to tell specific ResizingPanels/DockablePanes to always be present (lock them in the docking manager), even if they aren't visible.  This way their layout and orientation is retained even if all of the DockableContent in them is closed.  I'm creating an editor of sorts, and what I want is a main window where the document resides, then a number of tool panels to either side of the main window.  I want the layout to be such that there is a 4 to 1 difference between the widths of the main panel to the tools panel.  I can get this on my initial layout through several means, but once I close all of my windows and reopen a document (causing the tool panels and main window to open again), I can't get the same positioning I had when I started since DockingManager has killed the ResizingPanel and DockingPanes that I originally created.

 

May 28, 2010 at 12:11 AM
So I think I figured out how to do most of what I wanted to do.  I'm not sure if there lurks in here some hidden demon that will leap out and bite me, but it seems to work pretty well.  
I can close and reopen my various windows and have them pop back up in the exact place I want them.

One thing I am missing. If you drag a DockableContent from the viewPane, then the tools pane expands to the full length of the editor. I'd like it to just stay the size it is and not expand.
Is there an easy way to set this? Thanks for the help on this Ado.

// build up the resizing panel/dockable panels in code and store them off. // DockingManager dockManager; ResizingPanel resizerPanel = new ResizingPanel(); DockablePane toolsPane = new DockablePane(); DockablePane viewPane = new DockablePane(); resizerPanel.Children.Add(toolsPane); resizerPanel.Children.Add(viewPane); ResizingPanel.SetResizeWidth(viewPane, new GridLength(4.0, GridUnitType.Star)); ResizingPanel.SetResizeWidth(toolsPane, new GridLength(1.0, GridUnitType.Star)); dockManager.Content = resizerPanel; // later, if you ever see that the dockmanager content is not a resizer, then you need to rebuild your layout. Just re-add your panels/panes // rebuild the layout if it was lost. if (!(dockManager.Content is ResizingPanel)) { dockManager.Content = resizerPanel; resizerPanel.Children.Add(toolsPane); resizerPanel.Children.Add(viewPane); }