Debug assertion in SetupSplitters()

Dec 29, 2008 at 11:35 AM
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

Dec 30, 2008 at 1:03 PM
Can you please post your XAML code and describe better how to reproduce the issue?
Jan 5, 2009 at 10: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)
            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"
    Title="AvalonDock Demo" Height="600" Width="800">
    <DockPanel LastChildFill="True">
            <ScaleTransform ScaleX="1" ScaleY="1"/>
        <Menu DockPanel.Dock="Top" Name="menuStrip">
            <MenuItem Header="Layout">
                <MenuItem Header="Save" Click="MenuItemSave_Click" />
                <MenuItem Header="Load" Click="MenuItemLoad_Click" />
        <ToolBar DockPanel.Dock="Top" Name="toolBar" />
        <ContentControl x:Name="TestContainer">
            <ad:DockingManager x:Name="dockingManager">
                    <ad:DockablePane x:Name="dockablePane" />

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

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

Best Regards