0

I have the following AvalonDock (I'm using version 1.3) layout:

<AvalonDock:DockingManager Grid.Row="1"
                               x:Name="MainDockingManager"
                               Loaded="MainDockingManager_Loaded">
        <AvalonDock:ResizingPanel Orientation="Vertical">
            <AvalonDock:ResizingPanel Orientation="Horizontal">
                <AvalonDock:DockablePane x:Name="LeftDockablePane"
                                         AvalonDock:ResizingPanel.ResizeWidth="250" />
                <AvalonDock:ResizingPanel Orientation="Vertical">
                    <AvalonDock:DocumentPaneResizingPanel>
                        <AvalonDock:DocumentPane x:Name="documentPane"/>
                    </AvalonDock:DocumentPaneResizingPanel>
                    <AvalonDock:DockablePane x:Name="BottomDockablePane"
                                             AvalonDock:ResizingPanel.ResizeHeight="200" />
                </AvalonDock:ResizingPanel>
            </AvalonDock:ResizingPanel>
        </AvalonDock:ResizingPanel>
    </AvalonDock:DockingManager>

This is the event handler for the Loaded event of the DockingManager:

    void MainDockingManager_Loaded( object sender, RoutedEventArgs e )
    {
        _layoutStateFilePath = Path.Combine( ApplicationSettingsService.UserSettingsDirectory, LayoutStateFileName );

        if ( File.Exists( _layoutStateFilePath ) )
        {
            MainDockingManager.RestoreLayout( _layoutStateFilePath );
        }
    }

And the window closing event handler:

    private void ApplicationViewsWindow_Closing( object sender, CancelEventArgs e )
    {
        MainDockingManager.SaveLayout( _layoutStateFilePath );
    }

Saving and restoring of all the DockablePanes works fine, but the issue is that the DocumentPane is not restoring correctly. When I try to open new documents they do not show.

I've used the Immediate window in Visual Studio to make the following queries

Before calling MainDockingManager.RestoreLayout():

documentPane.IsMainDocumentPane
true

After calling RestoreLayout():

documentPane.IsMainDocumentPane
null
MainDockingManager.MainDocumentPane.GetHashCode()
16306004
documentPane.GetHashCode()
15125992

Doing this after calling RestoreLayout() doesn't work either:

MainDockingManager.MainDocumentPane = documentPane;

Any ideas what I'm doing wrong or if there's something I'm missing here?

alimbada
  • 1,392
  • 1
  • 12
  • 27

1 Answers1

0

I fixed this by not using the the named DocumentPane ("documentPane") when adding new documents. Instead I used the DockingManager.MainDocumentPane property to manipulate the DocumentPane.

alimbada
  • 1,392
  • 1
  • 12
  • 27