Hi Marc,
The AutoHideContainer instances (which hold a ToolWindow in auto-hide mode) are created on the control which is hosting DockManager. I put together a sample function to illustrate getting the AutoHideContainer for a particular side.
/// <summary>
/// Gets the AutoHideContainer, if any, on the given side of a DockManager.
/// </summary>
/// <param name="dockManager">The DockManager to examine.</param>
/// <param name="dockStyle">Indicates the left, top, right, or bottom side.</param>
/// <returns>An AutoHideContainer if found; otherwise false.</returns>
private AutoHideContainer GetAutoHideContainer(DockManager dockManager, DockStyle dockStyle) {
// Make sure the DockManager is hosted
if (dockManager.HostContainerControl != null) {
// Iterate all the controls on the host control
foreach (var control in dockManager.HostContainerControl.Controls) {
// Is the control an AutoHideContainer?
if (control is AutoHideContainer autoHideContainer) {
// Is the AutoHideContainer on the desired side?
if (autoHideContainer.Dock == dockStyle) {
return autoHideContainer;
}
}
}
}
// Not found
return null;
}
Then you could perform logic on your ToolWindow based on the presence of that AutoHideContainer.
// Create a new ToolWindow
ToolWindow toolWindow = CreateNewToolWindow();
// Look for an AutoHideContainer on the right side
var rightSideAutoHideContainer = GetAutoHideContainer(this.dockManager, DockStyle.Right);
if (rightSideAutoHideContainer != null) {
// Attach to the right side AutoHideContainer
toolWindow.DockTo(rightSideAutoHideContainer, DockOperationType.Attach);
}
else {
// Dock to the right of DockManager
toolWindow.DockTo(dockManager, DockOperationType.RightOuter);
// Change the state to auto-hide
toolWindow.State = ToolWindowState.AutoHide;
}
// Activate the new tool window
toolWindow.Activate();
This should get you what you were looking for if I understood the request correctly. Please reach out if it does not.