[Version 2.0] Empty LayoutAnchorablePane gets garbage collected

Dec 10, 2013 at 11:47 AM
Hello!

I tried to build up an application like in the MVVMTestApp-Example.
The difference is that I have some LayoutAnchorablePane's setup in xaml that are filled later.

If I leave these Panes empty at startup and want to add a child to them in the LayoutInitializer they aren't there anymore (I think they are garbage collected).

How can I solve this?

Here some code snippets:

In xaml:
            <avalonDock:LayoutRoot>
                <avalonDock:LayoutPanel Orientation="Vertical">
                    <avalonDock:LayoutDocumentPane/>
                    <avalonDock:LayoutAnchorablePane Name="ToolsPane1" DockHeight="150">
                    <!--Empty on initialization-->                    
                    <avalonDock:LayoutAnchorablePane Name="ToolsPane2" DockHeight="150">
                    <!--Empty on initialization-->
                    <avalonDock:LayoutAnchorablePane Name="ToolsPane3" DockHeight="150">
                    </avalonDock:LayoutAnchorablePane>
                </avalonDock:LayoutPanel>
            </avalonDock:LayoutRoot>
In the LayoutInitializer.cs:
if (...){
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane");
            if (toolsPane != null)
            {
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }
}
if (...){
var toolsPane2 = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane2");
            if (toolsPane != null)
            {
                toolsPane2.Children.Add(anchorableToShow);
                return true;
            }
}
if (...) {
var toolsPane3 = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane3");
            if (toolsPane != null)
            {
                toolsPane3.Children.Add(anchorableToShow);
                return true;
            }
}
Dec 26, 2013 at 5:13 PM
I am having the exact same problem.

I pre-setup some standard pane areas for tools, and based on the content of the anchorableToShow, I add it to the appropriate pane. Except that after adding the first pane from my AnchorablesSource, all the empty panes vanish and I can no longer (easily) position them.

I shouldn't have to write complex logic to try to determine which panes are already out there and then add ones that are missing.
Feb 3, 2014 at 2:39 PM
I have this issue also. Is there any way to prevent empty panes from being cleaned up?
Feb 4, 2014 at 6:47 AM
Hello,
even if it's not a "clean" solution I solved this issue by adding a "Dummy-Pane" that I never removed. So nothing is cleaned up and it works...
Feb 6, 2014 at 5:38 PM
OK, thanx, will try that.