SEN*_*Nya 3 c# visual-studio-sdk vsix vssdk visual-studio-2017
我正在开发 Visual Studio 2017 的扩展,其中包含自定义“工具窗口”。此“工具窗口”包含WPF control
订阅view model
的Workspace.WorkspaceChanged和EnvDTE.DTE.Events.WindowEvents.WindowActivated事件。
我知道,当用户关闭“工具窗口”时,它实际上并没有被破坏,而是“隐藏”了。然而,它仍然对我的事件做出反应。
所以,我想知道两个问题的答案:
编辑:创建工具窗口的代码:
protected virtual TWindow OpenToolWindow()
{
ThreadHelper.ThrowIfNotOnUIThread();
// Get the instance number 0 of this tool window. This window is single instance so this instance
// is actually the only one.
// The last flag is set to true so that if the tool window does not exists it will be created.
ToolWindowPane window = Package.FindToolWindow(typeof(TWindow), id: 0, create: true);
if (window?.Frame == null)
{
throw new NotSupportedException("Cannot create tool window");
}
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
return window as TWindow;
}
Run Code Online (Sandbox Code Playgroud)
要检测工具窗口何时关闭,您可以从IVsWindowFrameNotify3继承它,并在 OnShow 方法中检查 fShow == (int) __FRAMESHOW.FRAMESHOW_WinClosed。
归档时间: |
|
查看次数: |
969 次 |
最近记录: |