This project is read-only.

DockableContent close notification

May 25, 2009 at 10:48 AM

In my application i need to update other controls in case some some DockableContent disappears from the screen.


Is there a way to get notified when a DockableContent gets closed / hidden?



May 27, 2009 at 7:56 PM

Does the Unloaded event work for you?

Jun 18, 2010 at 11:17 PM

Ugh - I'm having the same problem.  I need to know when a dockable content is hidden when the user presses the 'X' in the upper right hand corner.  The only way I can do this is to turn HideOnClose to false, and then catching the close event.  I'm afraid this might screw up any layout saving I might want to do in the future.  I tried to respond to the IsVisibleChanged event, but that doesn't seem to fire either.  Unloaded did not work either.  How can I get updated on when a DockableContent is being hidden?

Jun 19, 2010 at 12:01 AM

In light of no better obvious solution, I've just added this to ManagedContent.cs :

 /// <summary>
        /// Event fired when the content has been closed
        /// </summary>
        /// <remarks>Note that when a document is closed property like <see cref="ManagedContent.ContainerPane"/> or <see cref="ManagedContent.Manager"/> returns null.</remarks>
        public event EventHandler Hidden;

        /// <summary>
        /// Ovveride this method to handle <see cref="DocumentContent.OnClosing"/> event.
        /// </summary>
        protected virtual void OnHidden()
            if (Hidden != null)
                Hidden(this, EventArgs.Empty);

Then I added the call to OnHidden in the DockableContent.Hide call, this seemed to get me what I want.  If there is a better way, I'm all ears (as I'd rather not divert from what is the main line).


Jun 19, 2010 at 1:41 PM


Have you tried to subscribe the StateChanged event? also which version are you using?


Jun 21, 2010 at 4:26 PM

Version 1.3.  Okay, that worked.  I tried using StateChanged before, but I was checking the "IsVisible" property instead of the State property.  So, when a dockableContent.State is "Docked", dockableContent.IsVisible can be false.  I think that was what was confusing - there are two properties that represent visibility (State and IsVisible), but only one of them appears to be used?  Anyways, I'll revert that one change to bring me back in line with the main code line.