如何通过Visual Studio中的函数调用显示ToolWindow

时间:2016-06-17 16:13:33

标签: c# visual-studio extension-methods

有没有办法通过函数调用显示ToolWindow?我知道教程https://msdn.microsoft.com/en-us/library/cc138567.aspx,它展示了如何通过包提供ToolWindow并将其添加到菜单中,但是,我正在寻找一种通过函数调用显示ToolWindow的方法。像这样:

void ShowToolWindow(){
  ToolWindowPane window = new ToolWindowPane();
  window.Content = myControl();
  frame = window.frame();
  frame.Show();
}

1 个答案:

答案 0 :(得分:1)

您指的教程实际上包括ShowToolWindow函数:

window = (FirstToolWindow) this.package.FindToolWindow(typeof(FirstToolWindow), 0, true);
if ((null == window) || (null == window.Frame))
{
  throw new NotSupportedException("Cannot create tool window");
}
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());