Я разрабатываю расширение для Visual Studio 2017, которое содержит пользовательское «окно инструментов».Это «окно инструментов» содержит WPF control
с view model
, подписанным на Workspace.WorkspaceChanged и EnvDTE.DTE.Events.WindowEvents.WindowActivation события.
IЗнайте, что когда «окно инструментов» закрыто пользователем, оно на самом деле не уничтожается, а «скрывается».Тем не менее, он все еще реагирует на мои события.
Итак, я хочу знать ответы на два вопроса:
- Как проверить, что окно инструмента скрыто?
- Можно ли "закрыть" окно инструмента, чтобы оно было разрушено?
РЕДАКТИРОВАТЬ: код для создания окна инструмента:
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;
}