Null pane with custom RemovePane method

0 Answers 30 Views
Docking
boon
Top achievements
Rank 1
boon asked on 31 May 2024, 10:04 AM

I'm getting a null reference exception when closing one of the pane and could not figure out why it is null in the RemovePane(RadPane pane) method.

We have override to that method,

protected override void RemovePane(RadPane pane)
        {
            if(pane.Header.ToString().ToLower()=="digital" || pane.Header.ToString().ToLower() == "analog")
                SaveDebugPaneLayout(pane);
            pane.DataContext = null;
            pane.Content = null;
            pane.ClearValue(RadDocking.SerializationTagProperty);
            pane.RemoveFromParent();
        }

And also the CreatePaneForItem method,

protected override RadPane CreatePaneForItem(object item)
        {
            var viewModel = item as DebugPaneViewModel;
            if (viewModel != null)
            {
                var pane = viewModel.IsDocument ? new RadDocumentPane() : new RadPane();

                pane.DataContext = item;
    
                if (viewModel.ContentType != null)
                {
                    if (viewModel.GetType().ToString().EndsWith("EditorViewModel")) 
                    {
                        if (pane.Content == null)
                        {
                            dynamic obj = Activator.CreateInstance(viewModel.ContentType);
                            pane.Content = obj;
                            obj.DataContext = viewModel;
                        }
                    }
                    else
                    {
                        pane.Content = Activator.CreateInstance(viewModel.ContentType);
                    }
                }

                RadDocking.SetSerializationTag(pane, viewModel.ID);
                return pane;
            }

            return base.CreatePaneForItem(item);
        }
How can I know which pane is null when it is executing the RemovePane(). I tried looking at when panes are being added but did not see anything suspicious.
Stenly
Telerik team
commented on 05 Jun 2024, 07:05 AM

Is there a possibility to share a sample project that reproduces the null reference exception or a bit more information so that I can reproduce it on my side? Also, what is the version of the assemblies that are used on your side?

No answers yet. Maybe you can help?

Tags
Docking
Asked by
boon
Top achievements
Rank 1
Share this question
or