SaveLayout()

Jun 8, 2009 at 5:30 PM

I am receiving the following error when I try and save the layout...

"Unable to serialize docking layout while DockingManager control is unloaded"  There were discussions on this topic, but the resolution wasn't clear to me.

Can someone tell me the guidelines for Saving the Layout?  i.e.  All elements must have a Name tag?

Thanks in advance!

Jun 8, 2009 at 5:41 PM

Here is what I came up with; fire an event after the docking manager loads...

 dockingManager.Loaded += new RoutedEventHandler(dockingManager_Loaded);

Handle all my saving there...works fine.

 

Now restore is my issue:  I receive an error:

"Specified argument was out of the range of valid values. Parameter name: index"

 

Jun 9, 2009 at 8:05 AM

All of your DockableContent must have the names!!! See the following example

  <ad:DockingManager Grid.Row="2" Name="dockMngr" Loaded="dockMngr_Loaded">
            <ad:ResizingPanel Orientation="Vertical">
                <ad:ResizingPanel Orientation="Horizontal">
                    <ad:DockablePane MinWidth="150" ad:ResizingPanel.ResizeWidth="150">
                        <ad:DockableContent Title="Navigation Tree" Name="_navigationTree">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="200*" />
                                    <RowDefinition Height="79.388*" />
                                </Grid.RowDefinitions>
                                <TreeView Name="treeViewNavigation" Grid.Row="0"/>
                                <Expander Grid.Row="1" Header="Описание" Margin="0,0,0,0" Name="DetailsExpander" IsExpanded="True">
                                    <TextBox MinHeight="30" Name="DetailsTextBlock" IsReadOnly="True" Width="Auto" TextWrapping="WrapWithOverflow" VerticalScrollBarVisibility="Auto" />
                                </Expander>
                            </Grid>
                        </ad:DockableContent>
                    </ad:DockablePane>
                    <ad:DockablePane>
                        <ad:DockableContent Title="Main Area" Name="_mainArea">
                            <ad:DocumentPane x:Name="documentsHost">
                                <ad:DockableContent Title="File1.doc">
                                    <RichTextBox/>
                                </ad:DockableContent>
                                <ad:DockableContent Title="File2.doc">
                                    <RichTextBox/>
                                </ad:DockableContent>
                            </ad:DocumentPane>
                        </ad:DockableContent>
                    </ad:DockablePane>
                </ad:ResizingPanel>
                <ad:DockablePane ad:ResizingPanel.ResizeHeight="150">
                    <ad:DockableContent Title="Журналы" Name="_logs">
                        <TabControl>
                            <TabItem Header="Журнал событий">
                                <dg:DataGrid Name="dataGridEventLog" Style="{StaticResource DataGridStyle}">
                                </dg:DataGrid>
                            </TabItem>
                            <TabItem Header="Системный журнал">
                                <dg:DataGrid Name="dataGridSysLog" Style="{StaticResource DataGridStyle}">
                                </dg:DataGrid>
                            </TabItem>
                        </TabControl>
                    </ad:DockableContent>
                </ad:DockablePane>
            </ad:ResizingPanel>
        </ad:DockingManager>

 

        private void dockMngr_Loaded(object sender, RoutedEventArgs e)
        {
            LoadLayout();
        }

        void LoadLayout()
        {
            string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
                + @"\layout.xml";
            if (!File.Exists(path))
            {
                Debug.Assert(false, "Отсутствует xml-файл, содержащий layout");
                return;
            }
            try{
                if (dockMngr != null)
                    dockMngr.RestoreLayout(path);
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }

Jun 20, 2009 at 10:34 AM
Edited Jun 20, 2009 at 10:35 AM

I found in AvalonDockTest Sample, after RestoreLayout, some autoHide Dockpanel such as server explorer can't to be floating!

who can make the sample  AvalonDockTest  to work correct?

Thanks!