Вопрос

I'm writing what I think should be a simple add-in for Visual Studio 2012 to pin a tab upon opening a file. I have the event being handled with this:

_documentEvents.DocumentOpened += DocumentEvents_DocumentOpened;

But within the method handling the event, the error message "Command "Window.PinTab" is not available." is being thrown. It happens for either line below (calling from ActiveWindow or calling from the document itself).

public void DocumentEvents_DocumentOpened(Document document)
{
            //document.DTE.ExecuteCommand("Window.PinTab");
            document.ActiveWindow.DTE.ExecuteCommand("Window.PinTab");
}

I see that that command returns false for IsAvailable, but how do I get it to be available? Or how do I call Window.PinTab such that it will be successfully executed?

Это было полезно?

Решение

So it turns out that the pin tab command has to be executed from the Window, not the Document object. Apparently all panes within the main Visual Studio windows are also windows.

This worked:

window.DTE.ExecuteCommand("Window.PinTab");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top