Debug assertion in SetupSplitters()

Dec 29, 2008 at 12:35 PM
Hello Avalon Team,

I am getting debug assertion in SetupSplitters()

Strack trace:
   at System.Windows.Media.VisualCollection.get_Item(Int32 index)
   at System.Windows.Controls.UIElementCollection.get_Item(Int32 index)
   at AvalonDock.ResizingPanel.SetupSplitters() in C:\AvalonDock\AvalonDock\ResizingPanel.cs:line 785

Exception Message

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

Could you give me a hint what am I doing wrong?

Best Regards
Rale



Dec 30, 2008 at 2:03 PM
Can you please post your XAML code and describe better how to reproduce the issue?
thanks,
ado
Jan 5, 2009 at 11:02 AM
Hi Ado

thanks for your reply. I found out what was the problem. The assertion was caused after hiding DocakbleContent after restoring layout.
Here is the code:

            this.dockingManager.RestoreLayout(new FileInfo(System.Windows.Forms.Application.LocalUserAppDataPath).Directory.FullName + "\\WindowLayout.xml");

            List<DockableContent> hideList = new List<DockableContent>();
            foreach (DockableContent content in this.dockingManager.DockableContents)
            {
                if (!content.IsVisible)
                {
                    hideList.Add(content);
                }
            }
            foreach (DockableContent content in hideList) this.dockingManager.Hide(content);

This code was introduced as I was getting following assertion while loading layout file:
Layout file hasn't a valid structure! in RestoreLayout(XmlDocument doc)

XAML code:
<Window x:Class="AvalonDockENM.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
    Title="AvalonDock Demo" Height="600" Width="800">
    <DockPanel LastChildFill="True">
        <DockPanel.LayoutTransform>
            <ScaleTransform ScaleX="1" ScaleY="1"/>
        </DockPanel.LayoutTransform>
        <Menu DockPanel.Dock="Top" Name="menuStrip">
            <MenuItem Header="Layout">
                <MenuItem Header="Save" Click="MenuItemSave_Click" />
                <MenuItem Header="Load" Click="MenuItemLoad_Click" />
            </MenuItem>
        </Menu>
        <ToolBar DockPanel.Dock="Top" Name="toolBar" />
        <ContentControl x:Name="TestContainer">
            <ad:DockingManager x:Name="dockingManager">
                <ad:ResizingPanel>
                    <ad:DockablePane x:Name="dockablePane" />
                </ad:ResizingPanel>
            </ad:DockingManager>
        </ContentControl>
    </DockPanel>
</Window>



Dynamically adding content:
        public void RegisterUserControl(System.Windows.Forms.UserControl control, string uniqueID)
        {
            // Create content
            DockableContent content = new DockableContent();
            content.Title = control.Name;
            content.Name = control.Name;
            content.Uid = uniqueID;

            // Create host since
            WindowsFormsHost host = new WindowsFormsHost();
            host.Child = control;
            content.Content = host;

            // Add content to pane
            this.dockablePane.Items.Add(content);
        }

I am still getting assertion in SetupSplitters() if I close all content/windows.

Best Regards
Rale