This project is read-only.

Close Event when closing in floating mode ?

Jun 24, 2009 at 10:33 AM

in my project I use "IsFloatingAllowed = true". When I close this window I never get a close-event.

What's wrong with that?



Jun 24, 2009 at 4:04 PM

To solve the problem I added the following method in DocumentFloatingWindow.cs:

        protected override void OnClosing(CancelEventArgs e)
            if (HostedPane.Items.Count == 1)
                    DocumentContent content = HostedPane.Items[0] as DocumentContent;
                catch { }

I think it's not the best but it works for me. I get now the missing Close-Event.



Jun 25, 2009 at 2:24 PM

Hi, thanks fot the code, it has been included in latest build! Ado

Sep 10, 2009 at 2:26 AM


The fix above only deals closing the window from the ui. But if you call Close() on the DocumentContent hosted in the floating window it still doesn't work.

The problem is in DocumentContent.InternalClose() - where it is only checking for the parentPane to be a DocumentPane.
I tried a quick fix by getting the container pane as a FloatingDockablePane, and call .Items.Remove(this).

This works, but leaves the floating window open if there are no more managedcontent to display.

The second problem happens if you explicitly call Close() on the FloatingDockablePane. This calls the DockablaPane.Close() method where it tries to cast the selected item as a DockableContent, which renders it null when the calls reach the DockingManager.Hide(DockableContent content).

So the entire issue gets fixed with this in the InternalClose()

FloatingDockablePane floatingParentPane = ContainerPane as FloatingDockablePane;
if (floatingParentPane != null)


However this presents other problems, ie why is the DocumentContent having to close a floating window?

What would be the logical way to do this given your current design?




Sep 10, 2009 at 11:46 AM


I'm using version 1.2.2632, if I drag a documentcontent out of the parent DocumentPane and than, as FloatingWindow, I close it I'm correctly receiving the Closing/Close event.

Are you using the from SVN?

Thanks, Ado

Sep 11, 2009 at 1:27 AM

I'm using the head revision on the svn (42303).

The problem is not when the user closes the window, rather when you call Close() on a DocumentContetn hosted on a FloatingDockablePane.

Thanks again,


Sep 11, 2009 at 10:56 AM


Thanks for the bug report, i found it and I've applied the fix you suggest. You're right when you say that this is a design-problem; actually I designed DocumentContents to be only hosted in DocumentPanes, so the problem.

Until I decided to simulate the VS2010 document floating behaviour everything worked "by-design".

In the future I'll create a new class called FloatingDocumentPane deriving from DocumentPane so that DocumentContent when floating will be hosted by that class instead by a FloatingDockablePane. this will ensure that the first cast of the InternalClose() method will work correctly:

DocumentPane parentPane = ContainerPane as DocumentPane;

but for the moment your workaround is ok, thanks again, you'll find it into the next build,



Sep 11, 2009 at 5:46 PM

Thanks Ado!

The FloatingDocumentPane makes sense.