force Auto-HideLeftContainer to dock on left side

Docking/MDI for WPF Forum

Posted 13 years ago by Rod Kuhns
Version: 10.2.0532
Avatar
I have a ToolWindow (named "autoHideLeft") within another ToolWindow. I want to force the autoHideLeft control (inner ToolWindow) to always dock on the left side of its parent window. The current behavior is that the inner ToolWindow will dock on the left as long as the parent ToolWindow is docked itself. When the parent ToolWindow is undocked and floating the inner ToolWindow will dock to the right when its pin is released. Hopefully this makes sense.

XAML snippet:

<docking:DockSite
x:Name="dockSite"
Grid.Row="1"
DockPanel.Dock="Left"
ToolWindowsHaveOptions="False"
CanToolWindowsDockRight="False"
>
<docking:DockSite.AutoHideLeftContainers>
<docking:ToolWindowContainer x:Name="docToolContainer" docking:DockSite.ControlSize="230, 575">
<docking:ToolWindow x:Name="autoHideLeft" Title="Layers" CanClose="False"
CanAutoHide="True" CanRaft="True" CanDockRight="False">
<ContentPresenter
Content="{Binding Path=LayerManagerViewModel, Mode=OneWay}">
</ContentPresenter>
</docking:ToolWindow>
</docking:ToolWindowContainer>
</docking:DockSite.AutoHideLeftContainers>


Another aspect of this issue seems to be related to how we persist and restore the docked state of the inner tool window.

We determine and save the state upon application exit with the following:
bool isLayerManagerDocked = (LayoutMap2View.Instance.autoHideLeft.State == ActiproSoftware.Windows.Controls.Docking.DockingWindowState.Docked);

Then we restore this state when the application starts back up with the following:
if (isLayerManagerDocked)
{
autoHideLeft.Dock(dockSite, ActiproSoftware.Windows.Controls.Docking.Direction.Left);
}

This seems to work well in restoring the state to either pinned open or not, but the side effect of this is the behavior explained above (docking to right side issue). The issue goes away when we don't restore state using this code. I don't understand the relationship here and why this would cause the autoHideLeft ToolWindow to dock to the right when it's parent window is not docked itself.

Any thoughts, ideas, or advice would be appreciated.

Comments (3)

Posted 13 years ago by Rod Kuhns
Avatar
This has been resolved...

The line:

autoHideLeft.Dock(dockSite, ActiproSoftware.Windows.Controls.Docking.Direction.Left);

was being run anytime the _Loaded method was run, which happens many times as the docking environment and docking states change. The solution was to use an initialized property and to check that so that this command would only run once when the application first loads.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Rod,

Glad to hear you worked it out. On a side note, you should never give ToolWidnowContainer, SplitContainer, or TabbedMdiContainer elements a name (i.e. x:Name). These elements are created and destroyed dynamically as document and tool windows are moved around. By naming them, you will effecitvely retain a reference to a container that is no longer used.


Actipro Software Support

Posted 13 years ago by Rod Kuhns
Avatar
Thank you! Very good information to know!
The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.