Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1425
Problem with TabGroupPaneRegionAdapter for infragistics
posted

Hi,

I am using TabGroupPaneRegionAdapter from https://compositewpfcontrib.svn.codeplex.com/svn/Trunk/src/Extensions.Infragistics/Composite.Wpf.Infragistics/CompositeWPFContrib.Composite.Wpf.Infragistics/XamDockManager/Regions/TabGroupPaneRegionAdapter.cs.

The problem I am getting with this is contentpane's Closed event executes two times which is probably due to line 'contentPane.ExecuteCommand(ContentPaneCommands.Close);' Which means when cross button was pressed and closed event was invoked first time it was still there in xamDockManager hence line "contentPane.ExecuteCommand(ContentPaneCommands.Close);" executes and invokes closed event again. Any ideas how to solve this.

Here is part of code from adapter:

private void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, TabGroupPane regionTarget)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                //Add content panes for each associated view. 
                foreach (object item in e.NewItems)
                {
                    UIElement view = item as UIElement;

                    if (view != null)
                    {
                        ContentPane newContentPane = new ContentPane();
                        newContentPane.Content = item;
                        //if associated view has metadata then apply it.
                        if (view.GetTabGroupPaneMetadata() != null)
                        {
                            newContentPane.Header = (view.GetTabGroupPaneMetadata()).Header;
                        }
                        //When contentPane is closed remove the associated region 
                        newContentPane.Closed += delegate(object contentPaneSender, PaneClosedEventArgs args)
                        {
                            OnContentPaneClosed((ContentPane)contentPaneSender, args, region);
                        };


                        regionTarget.Items.Add(newContentPane);
                    }
                }
            }
            else
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    //Associated View has been removed => remove the associated ContentPane from XamDockManager
                    XamDockManager xamDockManager = regionTarget.FindDockManager();
                    IEnumerable<ContentPane> contentPanes = xamDockManager.GetPanes(PaneNavigationOrder.VisibleOrder);

                    foreach (ContentPane contentPane in contentPanes)
                    {
                        if (e.OldItems.Contains(contentPane.Content))
                        {
                            contentPane.Content = null;
                            contentPane.CloseAction = PaneCloseAction.RemovePane;
                            contentPane.ExecuteCommand(ContentPaneCommands.Close);
                        }
                    }


                }
            }
        }

        private void OnContentPaneClosed(ContentPane contentPane, PaneClosedEventArgs args, IRegion region)
        {
            object view = contentPane.Content;
            if (region.Views.Contains(view))
            {
                region.Remove(view);
            }
        }


Any help will be much appreciated thanks.
Imad.

Parents
  • 138253
    Offline posted

    Hello Imad,

     

    Thank you for your post. I have been looking, but it seems like that I am missing something in your scenario, so if this is still an issue for you, could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.

     

    Looking forward for your reply.

Reply Children