Dirkster99 / AvalonDock

Our own development branch of the well known WPF document docking library
Microsoft Public License
1.39k stars 318 forks source link

Layout.CollectGarbage is removing my empty pane #448

Open furqansafdar opened 1 year ago

furqansafdar commented 1 year ago

So finally I have narrowed down the problem by investigating the issue in the AvalonDock code, but I am seeking assistance on my observation to figure out if it is a bug or my code issue.

So my XAML is the same as mentioned below. While calling LayoutInitializer I am attaching two of the anchorables to two panes, ErrorsPane and NotesPane but not attaching anything in FindPane. This anchorable is added to the pane when user press Ctrl + F keyboard shortcut but before even that while i am adding my Documents using DocumentsSource, the method DocumentsSourceElementsChanged in DockingManager class is fires and calling Layout?.CollectGarbage() which removes the empty panes. This is why I am lossing it.

<avalonDock:DockingManager
    x:Name="DockingManager"
    prism:RegionManager.RegionName="{x:Static fsx:RegionNames.TabRegion}"
    AnchorablesSource="{Binding Path=Anchorables}"
    Loaded="DockingManager_OnLoaded">
    <avalonDock:DockingManager.LayoutUpdateStrategy>
        <controls:LayoutInitializer />
    </avalonDock:DockingManager.LayoutUpdateStrategy>
    <LayoutRoot>
        <LayoutPanel Orientation="Horizontal">
            <LayoutPanel Orientation="Vertical">
                <LayoutDocumentPaneGroup>
                    <LayoutDocumentPane ShowHeader="False" />
                </LayoutDocumentPaneGroup>
                <LayoutAnchorablePaneGroup DockHeight="150" Orientation="Horizontal">
                    <LayoutAnchorablePane Name="ErrorsPane" />
                    <LayoutAnchorablePane Name="NotesPane" />
                </LayoutAnchorablePaneGroup>
            </LayoutPanel>
            <LayoutAnchorablePaneGroup x:Name="MyAnchorablePaneGroup" Orientation="Vertical">
                <LayoutAnchorablePane x:Name="FindPane" DockWidth="250" />
            </LayoutAnchorablePaneGroup>
        </LayoutPanel>
    </LayoutRoot>
</avalonDock:DockingManager>