Subscribing to ToolWindow Activate event. RRS feed

  • Question

  • Greetings.

    I have a VSIX project that creates several instances of a ToolWindow. I want to know when one of the instances is getting activated. For example, somebody clicked on the appropriate VS window or selected it from the Window menu. I can't find any easy way of implementing it. I tried embedding a frame into the ToolWindow content and subscribing to GotFocus event:

            private void MyHost_GotFocus(object sender, RoutedEventArgs e)
                int lastInstance = toolWindow.Instance;
                MyPackage myPackage = toolWindow.Package as MyPackage;
                myPackage.SetLastInstance( lastInstance);

    Unfortunately this does not cut it, as this event only gets fired if I click inside the control. It is not enough to just have the ToolWindow activated. So far I could not find any other event that would signal activation of my ToolWindow. Does anybody know how this can be implemented?

    Thank you in advance,


    Tuesday, April 30, 2019 3:07 AM


  • Use need to call IVsUIShell7.AdviseWindowFrameEvents to wire up your own IVsWindowFrameEvents interface. If you use GetService with SVsUIShell, you can cast the returned object to IVsUIShell7, and that should get you there.


    Ed Dore

    Wednesday, May 1, 2019 5:49 AM

All replies