Is there an event that fires when a custom dockable window is closed in ArcMap? My dockable window uses the Add-in pattern and hosts a WPF user control. It opens via a command button which is nested in an ArcGIS toolbar menu. I can listen to the OnUpdate() event of the command, however, this event will only fire when the menu is expanded. I need to know immediately when the window is closed so I can stop a background process.

3 Answers 3


This doesn't answer your question directly, but may be helpful.

Consider creating a timer that executes a method every X milliseconds. Then you can use this method to periodically check the properties of all kinds of objects, including the visibility of your dockable window. This way you can know if your window was closed.

Below is some relevant code to give you the idea. (I use several static variables and methods that I am not crazy about, but it works.)

I create a static method in my custom BaseCommand class to expose the visibility of the dockable window. The variable m_dockableWindow must be made static as well.

public static bool MyDockableWindowIsVisible
    get { return m_dockableWindow !=null && m_dockableWindow.IsVisible(); }

I setup the Timer code in a custom IExtension class.

Timer timer = new Timer();
timer.Interval = 500;
timer.Tick += timer_Tick;

The Timer Method checks the visibility of the Dockable Window.

void timer_Tick(object sender, EventArgs e)
    if (MyBaseCommand.MyDockableWindowIsVisible)
  • 1
    Thanks for your answer. I'm not a fan of the timer usage but it's a valid solution. I had to put a piece of code in my background process loop to periodically check if the window was visible. So basically it's a sort of timer. Jun 26, 2015 at 17:37

I was able to get around this same problem by overriding the OnVisibleChanged event within the dockable window itself:

    protected override void OnVisibleChanged(EventArgs e)

        if (base.Visible) // The DW will still be visible if it is being closed.
            ClearReportViewerSource(); // Whatever code you need to run.

This works for me if closing the DW from the command button or X'ing it out directly. In fact, seems that this event only fires when closing the dockable window and not when opening it.


This is only for WinForms - not WPF. It also seems that this event is called during docking and undocking the DW too so be aware of that when using this approach.

  • The OnVisibleChanged event isn't available in WPF dockable windows. This is a useful solution for WinForms though, thanks. Nov 11, 2015 at 0:49
  • Sorry - I overlooked the WPF comment in your original question. Also, I noticed today that this event gets called when docking the window too so I need to find a way around that.
    – Tim Sexton
    Nov 11, 2015 at 13:06

I found this thread in the old esri forums. There are several suggestions.

  • Thanks Duncan, I saw that thread before posting and it does have helpful info. It seemed like there was mixed results with subclassing and I didn't attempt it. I was hoping that there was something new in 10.x add-ins that triggers the event. In the end I'm just using a combination of the OnUpdate() event in the dockable window's command button and the IsVisible property from the WPF window to achieve the desired results. Sep 11, 2014 at 18:03
  • link broken here
    – Vidar
    Nov 7, 2017 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.