RadPane instance cannot be null. Make sure that override of DockingPanesFactory.GetPaneFromItem method returns a valid RadPane instance.

1 Answer 27 Views
Docking
Pete
Top achievements
Rank 1
Iron
Iron
Iron
Pete asked on 02 Nov 2021, 04:48 PM

I'm getting an exception when closing panes with no title:

System.ArgumentNullException
  HResult=0x80004003
  Message=RadPane instance cannot be null. Make sure that override of DockingPanesFactory.GetPaneFromItem method returns a valid RadPane instance.
Parameter name: pane
  Source=Telerik.Windows.Controls.Docking
  StackTrace:
   at Telerik.Windows.Controls.Docking.DockingPanesFactory.RemovePane(RadPane pane)
   at Telerik.Windows.Controls.RadDocking.OnPanesSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)

We don't have an override of DockingPanesFactory.GetPaneFromItem so I'm not clear what's going wrong here? Is a pane parameter being passed that's null?

This occurs when we execute 'close all but this pane" type operation.

1 Answer, 1 is accepted

Sort by
1
Accepted
Dilyan Traykov
Telerik team
answered on 05 Nov 2021, 10:11 AM

Hello Pete,

Thank you for the provided stack trace.

This exception is thrown from the default implementation of the RemovePane method of the DockingPanesFactory class which has the following definition:

        protected internal virtual void RemovePane(RadPane pane)
        {
            if (pane == null)
            {
                throw new ArgumentNullException("pane", "RadPane instance cannot be null. Make sure that override of DockingPanesFactory.GetPaneFromItem method returns a valid RadPane instance.");
            }

            pane.Header = null;
            pane.Content = null;
            pane.DataContext = null;
            pane.RemoveFromParent();
        }

As you can see, if the passed pane argument is null, the exception is thrown. As this method is normally called after the GetPaneFromItem method in the default implementation of the factory, that's why the error message advises checking this method.

        private void RemovePaneFromItem(object item)
        {
            var pane = this.DockingPanesFactory.GetPaneFromItem(this, item);
            this.DockingPanesFactory.RemovePane(pane);
        }

With this in mind, you can create a custom DockingPanesFactory, override the RemovePane method and then check the call stack to see why the RadPane instance is null.

If you cannot determine the cause of this exception, please share how you've defined the logic for the 'close all but this pane" operation. You can modify the sample project I've attached to my reply to demonstrate this.

Please let me know how this goes.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Pete
Top achievements
Rank 1
Iron
Iron
Iron
commented on 05 Nov 2021, 10:15 AM

Thanks!

I've tracked down a few bugs in our code and managed to prevent blank tabs appearing (due to using the serialization tag as a lookup) and that fixes our issues.

If I see blank tabs again, I'll come back here.

Tags
Docking
Asked by
Pete
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dilyan Traykov
Telerik team
Share this question
or