RadDocking + MEF + Prism 4 + RegisterViewWithRegion = Element already has a logical parent

3 posts, 1 answers
  1. stephan johnson
    stephan johnson avatar
    9 posts
    Member since:
    Dec 2009

    Posted 11 Aug 2011 Link to this post

    Hi,

    I have been stuck with this issue for 3 days now and I need to move on. I am attempting to convince a client to use Telerik + Prism 4 for a new project they are undertaking, however I cannot even show them how to add a document to a RadDock when they click a button in the Ribbon Bar.

    All of my problems center around our friend, the RadPaneGroupRegionAdapter and the implementation provided by Telerik. It simply does not work. I can register the views (documents) successfully on startup of the application, however as soon as my command attempts to execute the following code:
    m_RegionManager.RegisterViewWithRegion(WpfPrism.Infrastructure.Helpers.RegionNameHelper.Document, typeof(Views.Search)); 

    All is lost and I get the following error:

    System.InvalidOperationException was unhandled by user code
      Message=Element already has a logical parent. It must be detached from the old parent before it is attached to a new one.
      Source=PresentationFramework
      StackTrace:
           at MS.Internal.Controls.InnerItemCollectionView.AssertPristineModelChild(Object item)
           at MS.Internal.Controls.InnerItemCollectionView.Add(Object item)
           at System.Windows.Controls.ItemCollection.Add(Object newItem)
           at Telerik.Windows.Controls.RadSplitContainer.PrepareContainerForItemOverride(DependencyObject element, Object item) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Controls\Docking\Docking\Docking\RadSplitContainer.cs:line 689
           at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
           at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
           at System.Windows.Controls.Panel.GenerateChildren()
           at System.Windows.Controls.Panel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
           at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
           at System.Windows.Controls.ItemContainerGenerator.OnRefresh()
           at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
           at System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
           at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
           at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
           at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
           at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
           at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
           at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
           at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
           at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
           at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
           at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
           at MS.Internal.Data.EnumerableCollectionView.LoadSnapshot(IEnumerable source)
           at MS.Internal.Data.EnumerableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
           at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
           at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
           at Microsoft.Practices.Prism.Regions.ViewsCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\ViewsCollection.cs:line 124
           at Microsoft.Practices.Prism.Regions.ViewsCollection.NotifyReset() in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\ViewsCollection.cs:line 129
           at Microsoft.Practices.Prism.Regions.ViewsCollection.SourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\ViewsCollection.cs:line 255
           at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
           at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
           at System.Collections.ObjectModel.Collection`1.Add(T item)
           at Microsoft.Practices.Prism.Regions.Region.InnerAdd(Object view, String viewName, IRegionManager scopedRegionManager) in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\Region.cs:line 380
           at Microsoft.Practices.Prism.Regions.Region.Add(Object view, String viewName, Boolean createRegionManagerScope) in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\Region.cs:line 275
           at Microsoft.Practices.Prism.Regions.Region.Add(Object view) in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\Region.cs:line 246
           at Microsoft.Practices.Prism.Regions.Behaviors.AutoPopulateRegionBehavior.AddViewIntoRegion(Object viewToAdd) in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\Behaviors\AutoPopulateRegionBehavior.cs:line 84
           at Microsoft.Practices.Prism.Regions.Behaviors.AutoPopulateRegionBehavior.OnViewRegistered(Object sender, ViewRegisteredEventArgs e) in c:\release\WorkingDir\PrismLibraryBuild\PrismLibrary\Desktop\Prism\Regions\Behaviors\AutoPopulateRegionBehavior.cs:line 109
      InnerException:

    I've attached my sample that I want to present to the client, please have a look, maybe I'm just stupid. ...
    I have not attached my sample, there is no attach option...
  2. stephan johnson
    stephan johnson avatar
    9 posts
    Member since:
    Dec 2009

    Posted 11 Aug 2011 Link to this post

    Here is a link to where the solution can be found WpfPrism
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    George
    Admin
    George avatar
    1332 posts

    Posted 16 Aug 2011 Link to this post

    Hello Stephan,

     
    Please, refer to the following forum thread - http://www.telerik.com/community/forums/wpf/docking/453763-raddocking-mef-prism-4-registerviewwithregion-element-already-has-a-logical-parent.aspx


    Regards,
    George
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top