This project has moved. For the latest updates, please go here.
1
Vote

AvalonDock: Creating a floating window from a hidden item does not appear to be working properly

description

I'm trying to create a new floating window by wrapping something in Layout.Hidden but it's not working as expected.

I've tried using an approach like this:
LayoutAnchorableFloatingWindow f = new LayoutAnchorableFloatingWindow();
LayoutAnchorablePane ap = new LayoutAnchorablePane(item);
f.RootPanel = new LayoutAnchorablePaneGroup(ap);
dockingManager.Layout.FloatingWindows.Add(f);
But the window never appears. The window does show in the ctrl-tab list and it does get serialized out.

Only if I reserialize the layout does the floating window appear.

What needs to be done to get this to work properly?

comments

theficus wrote Jun 28 at 7:56 PM

To work around this I needed to code in a complete hack. I'm hoping there's a better way to do this.
LayoutAnchorableFloatingWindow lfw = new LayoutAnchorableFloatingWindow();
LayoutAnchorablePane lap = new LayoutAnchorablePane(layoutAnchorable);
lap.Parent = lfw;
lfw.RootPanel = new LayoutAnchorablePaneGroup(lap);
lfw.Parent = dm.Layout;                    
dm.Layout.FloatingWindows.Add(lfw);
                    
// Hack
LayoutAnchorableFloatingWindowControl lfwc = (LayoutAnchorableFloatingWindowControl)Activator.CreateInstance(typeof(LayoutAnchorableFloatingWindowControl), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { lfw }, CultureInfo.InvariantCulture);
dm.UpdateLayout();
lfwc.Width = 300;
lfwc.Height = 300;
lfwc.Topmost = true;
lfwc.Show();