2 回答
TA贡献1790条经验 获得超9个赞
要检测工具窗口何时关闭,您可以从IVsWindowFrameNotify3继承它并在 OnShow 方法中检查 fShow == (int) __FRAMESHOW.FRAMESHOW_WinClosed。
TA贡献1807条经验 获得超9个赞
只是为了添加到@Sergey Vlasov 的回答 - 我发现了第二种方法,如果窗口被隐藏/显示,则会收到通知。这是我的 WPF 控件视图模型中的代码。
EnvDTE.DTE dte = MyVSPackage.Instance.GetService<EnvDTE.DTE>();
// _visibilityEvents is a private field.
// There is a recommendation to store VS events objects in a field
// to prevent them from being GCed
_visibilityEvents = (dte?.Events as EnvDTE80.Events2)?.WindowVisibilityEvents;
if (_visibilityEvents != null)
{
_visibilityEvents.WindowShowing += VisibilityEvents_WindowShowing;
_visibilityEvents.WindowHiding += VisibilityEvents_WindowHiding;
}
- 2 回答
- 0 关注
- 76 浏览
添加回答
举报