Udostępnij za pośrednictwem


Extend and customize tool windows

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Visual Studio provides several different types of windows, for example tool windows, document windows, and dialog windows. Other windows such as the Properties window, the Output window, and the Task List window, are types of tool windows.

Tool windows

Visual Studio tool windows are usually read-only windows that are not file-based. In this they differ from document windows, which display files in read-write mode. The Toolbox, Solution Explorer, Properties window, and Web Browser are examples of tool windows.

To find out how to create a simple tool window, see Add a tool window.

To register a tool window with Visual Studio, see Register a tool window.

Tool windows are single-instance by default, meaning that only one instance of the tool window can be open at a time. After a single-instance tool window is opened, it remains open until the IDE is closed. When you close a single-instance tool window, only its visibility changes. You can also create multi-instance tool windows, such that multiple instances of the window can be open simultaneously. See Create a multi-instance tool window for more information.

Tool windows can be dynamic, meaning that they are visible whenever their related UI context applies. The use of auto-visibility can reduce the clutter of windows in the IDE. For more information, see Open a dynamic tool window.

Tool windows can be docked, floating, or tabbed in the document frame. The tool window frame is provided by the IDE and is used to control the size, location, docking state, and other persistent properties. The tool window pane displays the contents. The default size and location apply only when the tool window is first opened; after that the tool window state is persisted.

Tool window panes can host WPF user controls and support toolbars. You can override the Window property to return the handle of the hosted control.

You can add many different features to tool windows. For example, you can add a toolbar: Add a toolbar to a tool window or a shortcut menu: Add a shortcut menu in a tool window. You can add a Search control that allows you to search items inside your tool window: Add search to a tool window.

You can subscribe to tool window events: Subscribe to an event.

Extend existing tool windows

You can add information about your tool window to a new Options page and a new setting on the Properties page, write to the Task List and Output windows. For more information, see Extend the Properties, Task List, Output, and Options windows.

In a Visual Studio extension you should create modal dialog boxes by deriving them from Microsoft.VisualStudio.PlatformUI.DialogWindow, which allows you to control them and the rest of the UI. For more information, see Create and manage modal dialog boxes.

See also