DocumentPane and ResizePanel

Feb 26, 2009 at 8:58 AM
Hi!

I'm trying to set a ResizingPanel.ResizeWidth to a DocumentPane and it doesn't work. I saw in the demo that the ResizePanel properties works only with DockablePane but haven't any effects on a DocumentPane.


For example :

<ad:DocumentPane x:Name="_documentsHost" ad:ResizingPanel.ResizeWidth="200">--> The size will not be 200...
<ad:DockablePane x:Name="_dockableHost" ad:ResizingPanel.ResizeWidth="200">--> The size will be 200...

Is anybody knows why? Or there is another solution to set (progammaticly) the prefered size of a DocumentContent or a DocumentPane.

Thank you!!!
Feb 26, 2009 at 4:02 PM
DocumentPanes always accopies all the available space, at least using the default template.
Why you should set to a preferred size for it?
Feb 27, 2009 at 9:47 AM
Edited Feb 27, 2009 at 9:50 AM
In fact I have a DockingManager which might contain lot of DocumentPane.
I would offer a button to the user to redraw the DockingManager. In redraw, I mean take all DocumentPane and place them all in a square of equal distributed size.

For example :

Before redraw :  

DocPane 1
DocPane 2
DocPane 3
DocPane 6
DocPane 4
DocPane 5

After redraw (progammaticly) :

DocPane 1
DocPane 2
DocPane 3
DocPane 4
DocPane 5
DocPane 6

So, that's why I prefer to set a prefered size ;)

Thank you!
Feb 27, 2009 at 11:17 AM
Ok, try to use code like this:

<ad:DockingManager>
<ad:DocumentPaneResizingPanel Orientation="Vertical">
<ad:DocumentPaneResizingPanel>
<ad:DocumentPane>
<ad:DocumentContent x:Name="doc1" Title="Doc1" />
</ad:DocumentPane>
<ad:DocumentPane>
<ad:DocumentContent x:Name="doc2" Title="Doc2" />
</ad:DocumentPane>
</ad:DocumentPaneResizingPanel>
<ad:DocumentPaneResizingPanel ad:ResizingPanel.ResizeHeight="200">
<ad:DocumentPane>
<ad:DocumentContent x:Name="doc3" Title="Doc3" />
</ad:DocumentPane>
<ad:DocumentPane >
<ad:DocumentContent x:Name="doc4" Title="Doc4" />
</ad:DocumentPane>
</ad:DocumentPaneResizingPanel>
</ad:DocumentPaneResizingPanel>
</ad:DockingManager>

DocumentPaneResizingPanel class is the key, it's the preferred container for
document panes.

Ado
Feb 27, 2009 at 1:01 PM
It looks good but I missed to precise that I need to do this progammaticly because I don't know the number of DocumentPane present in the DockingManager...
I have to create the structure you wrote programmaticly...

Something like that :

DocumentPaneResizingPanel.SetResizeWidth(myDockManager, 200); //For orientation???

foreach (DocumentPane document in myDockManager.Documents) {
    DocumentPaneResizingPanel.SetResizeWidth(document , 200);
    myDockManager.Anchor(document , documentRelative, AnchorStyle.Bottom OR Right); //I have a specific code to get the relative Pane and the AnchorStyle which run correctly...
}

but it doesn't work...

Feb 27, 2009 at 2:38 PM
Programmatically at runtime is more complicated because you need to
completely discard the current layout and recreate a new one from scratch.
This is a way to achive that, of course is not much tested:

DocumentPaneResizingPanel panelContainer =
_dockingManager.MainDocumentPane.Parent as DocumentPaneResizingPanel;
DocumentContent[] docs = _dockingManager.Documents;
//if panelContainer == null it means that we have a only docuument pane with
all contents in it
if (panelContainer == null)
{
ResizingPanel originalParentContainer =
(ResizingPanel)_dockingManager.MainDocumentPane.Parent;
int indexOfMainDocumentPane =
originalParentContainer.Children.IndexOf(_dockingManager.MainDocumentPane);
panelContainer = new DocumentPaneResizingPanel();
if (originalParentContainer.Orientation == Orientation.Horizontal)
ResizingPanel.SetResizeWidth(panelContainer,
ResizingPanel.GetResizeWidth(_dockingManager.MainDocumentPane));
else
ResizingPanel.SetResizeHeight(panelContainer,
ResizingPanel.GetResizeHeight(_dockingManager.MainDocumentPane));
originalParentContainer.Children.RemoveAt(indexOfMainDocumentPane);
originalParentContainer.Children.Insert(indexOfMainDocumentPane,
panelContainer);
}
panelContainer.Children.Clear();
panelContainer.Orientation = Orientation.Horizontal;
bool mainDocumentPaneIsSet = false;
foreach (DocumentContent doc in docs)
{
DocumentPane oldContainerPane = doc.Parent as DocumentPane;
oldContainerPane.Items.Remove(doc);
DocumentPane docPane = null;
if (mainDocumentPaneIsSet)
docPane = new DocumentPane();
else
{
docPane = _dockingManager.MainDocumentPane;
mainDocumentPaneIsSet = true;
}
ResizingPanel.SetResizeWidth(docPane, 200);
docPane.Items.Add(doc);
panelContainer.Children.Add(docPane);
}

Ado
Mar 8, 2009 at 1:29 PM
Hi ado!

Sorry to answer you only now but my planning is very busy..
I used your code with some improvements and the result is absolutly perfect!

FYI I'm working on a project in Switzerland (Fribourg). Your DockingManager is used to show many video streams.
I want to say you a big THANK YOU!!!

If you want to know more about my project, tell me.

See you!