Floating DockableContent doesn't resume to its former place

Oct 8, 2010 at 3:36 AM
Edited Oct 8, 2010 at 3:38 AM

Hi everybody,


I found an issue about the position-resuming function in AvalonDock.

If I close a DockableContent and then call the DockableContent.Show(DockingManager) method, at most occasions, the DockableContent goes back to its former location. 

But if the DockableContent is floating before it's closed, then instead of showing up floating it'll just go to the right side of the docking manager (or the position it was in before it's floating).


This looks like a minor issue, hope it'll be fixed.


Regards,

Cui

Oct 8, 2010 at 5:38 AM
Edited Oct 8, 2010 at 8:09 AM

Hi,

 

I found this code when I was trying to figure out why it's not going back to its former place:

 

 

        internal void Hide(DockableContent content)
        {
           ......

            if (content.State != DockableContentState.FloatingWindow &&
                content.State != DockableContentState.DockableWindow)
            {
                //save position only if hiding from a docked or autohidden pane
                content.SaveCurrentStateAndPosition();
            }
          ......
         }

 

It says "save position only if hiding from a docked or autohidden pane" in the comment, but why is that?

I added one line of code to save position and state when it's floating:

if (content.State == DockableContentState.FloatingWindow ||
                content.State == DockableContentState.DockableWindow)
            {
                //I added this line of code
                content.SaveCurrentStateAndPosition();

                DockableFloatingWindow floatingWindow = Window.GetWindow(content) as DockableFloatingWindow;

                if (floatingWindow != null &&
                    (floatingWindow.Content as Pane).HasSingleItem &&
                    !floatingWindow.IsClosing)
                {
                    floatingWindow.Close();
                }
            }

 

And it worked.

I don't know if this will cause any side effects, hope you can confirm it.

 

Thanks,

Cui