When creating an Extension for Visual Studio 2013 a tool window gets set up by default. However, I'd like to have a second tool window and can't see how one is supposed to go about that.
-
2Be aware the correct terminology is _extension_ not _plug-in_. – Feb 11 '15 at 09:10
-
That's what I thought at first as well - but then everybody spoke of a "Plugin". Edited my post. – mYnDstrEAm Feb 11 '15 at 09:16
-
2Actually the proper term in your scenario is "Package", which is the only kind of extension able to add a toolwindow. The other one would be "Add-In" but add-ins are deprecated in VS 2013 and will be removed in VS 2015. – Carlos Quintero Feb 13 '15 at 12:37
2 Answers
I have created a guide:
HOWTO: Create a toolwindow with a ToolWindowPane class in a Visual Studio package http://www.visualstudioextensibility.com/2015/02/20/mz-tools-articles-series-howto-create-a-toolwindow-with-a-toolwindowpane-class-in-a-visual-studio-package/

- 4,300
- 1
- 11
- 18
Well I just found a few things - so I'm gonna answer my own question so that other people having the same problem may take advantage of it:
Set up your extension as in this tutorial but check "Tool Window"
Create a new UserControl for the ToolWindow "ToolWindow2Control" and copy paste the contents of ToolWindowControl.xaml & ToolWindowControl.xaml.cs accordingly
Add a class "ToolWindow2" and copy paste the contents from ToolWindow.cs. Change the GUID to a new one (Tools->Create GUID)
In NameOfYourProject.vsct add the code for displaying a second entry in View->Other Windows by duplicating the Button found in the Buttons section. Change the ButtonText, the priority, the id of the Button and the id of the Icon.
Add the id of the Button to the entries under Symbols on the bottom of the page. It should be a third entry under guidNameOfYourProjectCmdSet.
Open PkgCmdID.cs (or PkgCmdIDList.cs) and add the id of the Button there as well, e.g.
public const uint cmdidMyTool2 = 0x102;
Add another icon to your project / resources. Then add another Bitmap entry in the Bitmaps section of NameOfYourProject.vsct with the GUID-id that you previously gave the Icon. Like so:
<Bitmap guid="guidImages2" href="Images\test.ico" usedList="testIcon"/>
And create another GuidSymbol entry in the Symbols section with a new GUID and a single IDSymbol entry which has the same name as the one you used in the usedList, like so:
<GuidSymbol name="guidImages2" value="{7BC1F97F-2693-4186-91CC-A35AE95886CE}" > <IDSymbol name="testIcon" value="1" /> </GuidSymbol>
Add this line to NameOfYourProjectPackage.cs:
[ProvideToolWindow(typeof(ToolWindow2))]
In NameOfYourProjectPackage.cs edit the Initialize method by copy-pasting the 3 lines under
// Create the command for the tool window
beneath it. In the first line use the id we gave in step #6 (cmdidMyTool2). In the 2nd line use a new MenuCommand Event handler ShowToolWindow2. And change the variable names.Create a new method ShowToolWindow2. Copy paste from the ShowToolWindow method and change the typeof in the first line to ToolWindow2
This should be it. I hope I haven't forgot anything. You can then open the two windows under Views->Other Windows

- 751
- 2
- 8
- 26
-
Yes, that's correct. Toolwindows in packages require two files (usercontrol and class) and some glue with attributes, callback methods and duplicated declaration of Guids and Ids. – Carlos Quintero Feb 13 '15 at 12:42
-
Yes - really wondering why noone seems to have thought about creating a simple guide for it. – mYnDstrEAm Feb 18 '15 at 15:39