Docked Tool Windows
Tool windows in docked state appear docked in containers around an optional workspace within their dock host. When two or more tool windows are in the same container, tabs allow for selecting which one is visible.
When a tool window is docked, it appears within a ToolWindowContainer.
The Solution Explorer tool window docked
Allowing Docking
Only tool windows can be docked. A global DockSite.CanToolWindowsDock property (defaults to true
) determines the default value for whether they have that capability, but it can be overridden at an instance-level by setting the DockingWindow.CanDock property.
The DockingWindow.CanAttach property can be set to false
to prevent a tool window from attaching (becoming tabbed with) another tool window in the same container.
Programmatically Docking a Tool Window
A tool window can be programmatically docked by calling the ToolWindow.Dock method. An overload of the method allows you to specify the IDockTarget and Side against which to dock around the target.
The IDockTarget can be a DockSite, DockHost, Workspace, or another docking window.
Appearance Options
These options control the appearance of tool window containers:
Member | Description |
---|---|
DockSite.ToolWindowsHaveCloseButtons Property |
Gets or sets whether |
DockSite.ToolWindowsHaveOptionsButtons Property |
Gets or sets whether |
DockSite.ToolWindowsHaveTitleBarIcons Property |
Gets or sets the global setting for whether tool window title bars display the icon of the selected tool window. |
DockSite.ToolWindowsHaveTitleBars Property |
Gets or sets the global setting for whether tool windows display a title bar when not in MDI. |
DockSite.ToolWindowTabItemContainerStyle Property |
Gets or sets the |
The ToolWindowContainer control also defines TitleBarMinHeight, TitleFontFamily, and TitleFontSize properties that can adjust the look of a title in a tool window container. These properties can only be altered with an implicit Style
that targets ToolWindowContainer that is in your application's Resources
.
Title vs. Tab Text
The DockingWindow.Title property is normally set to determine the title text that is rendered in tabs as well as in title bars and on the standard switcher. In some cases, it might be desirable to have longer text for the Title, such as "Properties - Document1.txt"
, while having shorter text that renders on tabs, such as "Properties"
. This allows your title to provide more extensive contextual information.
By setting the TabText property to a non-null
value, its value will be used to render the tab text instead of the Title value. In that scenario, the Title value will still be used in title bars and on the standard switcher when the window is selected.
Tab Tool Tip
The DockingWindow.TabToolTip property is automatically bound to the Title property for tool windows. Override the TabToolTip property to set alternate tool tip content.
Tab Images
By default, the DockingWindow.ImageSource image will not appear on tool window tabs.
You can force the image to display on the tabs by setting the DockSite.ToolWindowsHaveTabImages property to true
.
Tab and Title Bar Contextual Content
Tool window tabs and tool window container title bars can display any context-related content to the right of the title. This content is set via the ToolWindow.ToolWindowContainerTabContextContentTemplate and ToolWindow.ToolWindowContainerTitleBarContextContentTemplate properties respectively.
See the Contextual Content topic for some more information.
Tab Strip Placement
By default, the tool window tabs will appear below their content, but can be changed to appear on any side of the content.
You can alter the location of the tool window tabs by changing the value of the DockSite.ToolWindowsTabStripPlacement property.
Tab Overflow Behavior
There are numerous options from the TabOverflowBehavior enumeration for selecting what happens when the tabs overflow the available tab strip space.
By default, the tabs shrink to fit within the available tab strip space. This can be changed via the DockSite.ToolWindowsTabOverflowBehavior property.
Single Tab Behavior
Use the DockSite.ToolWindowsSingleTabLayoutBehavior property to adjust whether tool window containers that have a single tool window should show a tab or not. By default, tabs only show when there are two or more tool windows in a container.
Keyboard Shortcuts
The Alt+- keyboard shortcut shows the options menu for the currently selected tool window in the container.
Other keyboard shortcuts allow you to jump directly to a tab. Ctrl+1 will activate the first tab, with Ctrl+2 activating the second tab, and so on.