RestoreLayout

Sep 23, 2008 at 4:32 PM
I have a question about RestoreLayout (maybe it's a bug).

I have a dockablecontent. I have several different contextes that my application can have, for example User and Project. For a User context, a different layout is required than for the Project context.

My user context hides the project explorer dockable content. As soon as the context changes, my application calls DockingManager.RestoreLayout with a new layout file where the only difference is that autohide="true" instead of false for the project explorer dockable content.

However, a null-pointer exception occurs:

TargetSite: {Void ToggleAutoHide(AvalonDock.DockablePane)}

StackTrace:

"   at AvalonDock.DockingManager.ToggleAutoHide(DockablePane pane)\r\n   at AvalonDock.DockingManager.DetachContentFromDockingManager(DockableContent content)\r\n   at AvalonDock.DockingManager.RestoreLayout(XmlElement panelElement, DockableContent[] dockableContents)\r\n   at AvalonDock.DockingManager.RestoreLayout(XmlElement panelElement, DockableContent[] dockableContents)\r\n   at AvalonDock.DockingManager.RestoreLayout(XmlElement panelElement, DockableContent[] dockableContents)\r\n   at AvalonDock.DockingManager.RestoreLayout(XmlDocument doc)\r\n   at AvalonDock.DockingManager.RestoreLayout(String filename)\r\n   at ... (now it goes to my application).

Am I doing something wrong or is this a bug?
Sep 24, 2008 at 7:01 AM
Further investigated this problem. In the method AvalonDock.DockingManager.ToggleAutoHide, the _flyoutWindow is null.

I think this has to do with another problem that a floating window sometimes docks at the wrong location. The button to expand the DockablePanel is in the left top, but the panel expands right.
Sep 24, 2008 at 8:01 AM
Edited Sep 24, 2008 at 8:05 AM

It seems I have fixed the bug by replacing this line:

DockableContent selectedContent = _flyoutWindow.ReferencedPane.Items[0] as DockableContent;


by 

DockableContent

 

selectedContent = (_flyoutWindow != null) ? _flyoutWindow.ReferencedPane.Items[0] as DockableContent : pane.Items[0] as DockableContent;

 

 

 

 

In DockingManager.ToggleAutoHide (just after the RemovePaneFromTabGroups method call).

Can you confirm that this is correct? It seems to work fine here!

Sep 25, 2008 at 1:17 PM
Hi, I implemented your solution and seems to work fine. I hope to have more time to test it. I'll put this correction in next version. Thanks, ado