This is a migrated thread and some comments may be shown as answers.

MVVM Prism

9 Answers 486 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Garry
Top achievements
Rank 1
Garry asked on 09 Feb 2010, 01:50 AM
I've been toying around with trying to load modules in DockPanes using MVVM Prism. I can do it with Tabs, but have not been able to figure out how to do it with DockPanes.

Any ideas?

I get the below cast error when I try and add the module to a Region.

Microsoft.Practices.Composite.Modularity.ModuleInitializeException was unhandled  
  Message="An exception occurred while initializing module 'Help'. \r\n    - The exception message was: Unable to cast object of type 'VistaAdmin.Help.Presentation.HelpView' to type 'Telerik.Windows.Controls.RadPane'.\r\n    - The Assembly that the module was trying to be loaded from was:VistaAdmin.Help, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\r\n    Check the InnerException property of the exception for more information. If the exception occurred while creating an object in a DI container, you can exception.GetRootException() to help locate the root cause of the problem. \r\n  " 
  Source="Microsoft.Practices.Composite" 
  ModuleName="Help" 
  StackTrace:  
       at Microsoft.Practices.Composite.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 106  
       at Microsoft.Practices.Composite.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 68  
       at Microsoft.Practices.Composite.Modularity.ModuleManager.InitializeModule(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 248  
       at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModulesThatAreReadyForLoad() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 209  
       at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModuleTypes(IEnumerable`1 moduleInfos) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 168  
       at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModulesWhenAvailable() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 142  
       at Microsoft.Practices.Composite.Modularity.ModuleManager.Run() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 71  
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.InitializeModules() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 239  
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 112  
       at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 69  
       at VistaAdmin.Shell.App.RunInDebugMode() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Shell\App.xaml.cs:line 44  
       at VistaAdmin.Shell.App.OnStartup(StartupEventArgs e) in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Shell\App.xaml.cs:line 25  
       at System.Windows.Application.<.ctor>b__0(Object unused)  
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)  
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)  
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()  
       at System.Threading.ExecutionContext.runTryCode(Object userData)  
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)  
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)  
       at System.Windows.Threading.DispatcherOperation.Invoke()  
       at System.Windows.Threading.Dispatcher.ProcessQueue()  
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)  
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)  
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)  
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)  
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)  
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)  
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)  
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)  
       at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)  
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)  
       at System.Windows.Application.RunInternal(Window window)  
       at VistaAdmin.Shell.App.Main() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Shell\obj\Debug\App.g.cs:line 0  
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)  
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()  
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)  
       at System.Threading.ThreadHelper.ThreadStart()  
  InnerException: System.InvalidCastException  
       Message="Unable to cast object of type 'VistaAdmin.Help.Presentation.HelpView' to type 'Telerik.Windows.Controls.RadPane'." 
       Source="Telerik.Windows.Controls.Docking" 
       StackTrace:  
            at Telerik.Windows.Controls.RadPaneGroup.OnItemsChanged(NotifyCollectionChangedEventArgs e) in c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Docking\Docking\RadPaneGroup.cs:line 964  
            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.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)  
            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:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\Docking\Docking\RadSplitContainer.cs:line 673  
            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.addChildren(GeneratorPosition pos, Int32 itemCount)  
            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.OnItemAdded(Object item, Int32 index)  
            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.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.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)  
            at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)  
            at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)  
            at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)  
            at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)  
            at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)  
            at System.Collections.ObjectModel.Collection`1.Add(T item)  
            at MS.Internal.Data.EnumerableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)  
            at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)  
            at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.cs:line 102  
            at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.AddAndNotify(IList items) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.Desktop.cs:line 30  
            at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.UnderlyingCollection_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.cs:line 142  
            at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)  
            at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)  
            at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)  
            at System.Collections.ObjectModel.Collection`1.Add(T item)  
            at Microsoft.Practices.Composite.Presentation.Regions.Region.InnerAdd(Object view, String viewName, IRegionManager scopedRegionManager) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 313  
            at Microsoft.Practices.Composite.Presentation.Regions.Region.Add(Object view, String viewName, Boolean createRegionManagerScope) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 218  
            at Microsoft.Practices.Composite.Presentation.Regions.Region.Add(Object view) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 189  
            at VistaAdmin.Help.Applications.ModuleController.ShowHelpView() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Help\Applications\ModuleController.cs:line 55  
            at VistaAdmin.Help.Applications.ModuleController.ShowContents() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Help\Applications\ModuleController.cs:line 62  
            at VistaAdmin.Help.Applications.ModuleController.Initialize() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Help\Applications\ModuleController.cs:line 47  
            at VistaAdmin.Help.Module.Initialize() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Help\Module.cs:line 34  
            at Microsoft.Practices.Composite.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 64  
       InnerException:   
 

9 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 09 Feb 2010, 09:43 AM
Hi Garry,

 Most probably the problem is caused, because the default region adapter for ItemsControl (the TabControl and PaneGroup are ItemsControls) is using the ItemsSource property and unfortunately the RadPaneGroup control doesn't support this, because it is using the Items property internally. Please check the following article that shows how to create a custom region adapter for the RadPaneGroup control:

http://blogs.telerik.com/miroslavnedyalkov/posts/09-08-31/using_the_raddocking_control_with_prism.aspx

Hope this helps.

Sincerely yours,
Miroslav Nedyalkov
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Garry
Top achievements
Rank 1
answered on 09 Feb 2010, 03:45 PM
Miroslav,
That worked like a charm! I can't explain why a Custom Region Adapter never popped into my brain as I have had to use them in the past to achieve similar things. I guess I will use the excuse that this i the first tiem I am trying to integrate WPF RadControls in one of my apps.

You wouldn't have an already finsihed RegionAdpater for the RibbonBar sitting around somewhere would you? I know it would basically use the same concept, but if you happened to have one then it would save me a little time. That's my next task is to replace a toolbar with your RibbonBar.

Thanks as always!
0
Valentin.Stoychev
Telerik team
answered on 12 Feb 2010, 10:18 AM
Hi Garry Clark,

We have users using the RibbonBar with Prism without problems. Let us know if you face with any.

Best wishes,
Valentin.Stoychev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Garry
Top achievements
Rank 1
answered on 23 Feb 2010, 09:32 PM
Miroslav,
OK new situation. I have a DocumentHost that I am trying to now add RadDocumentPanes to. I have modified the RadGroup region adpater as such to accomodate this new type. Code is below. However I am now receiving an error of

"Element already has a logical parent. It must be detached from the old parent before it is attached to a new one." I have attached the full error details below.

Also to note that if I change the type back to RadPane it works properly. If I leave the RegionAdpater as was, but try and add a RadDocumentPane to a RadPaneGroup then I get an Object not set to an instance error.

Have any ideas? Do I perhaps need to create another regionadapter for type DocumentHost? That doesn't make sense to me as I am actually adding the RadDocumentPane to a RadPaneGroup the same as I do with RadPanes, but just a thought.

RegionAdapter Code

Have any ideas? Do I perhaps need to create another regionadapter for type DocumentHost? That doesn't make sense to me as I am actually adding the RadDocumentPane to a RadPaneGroup the same as I do with RadPanes, but just a thought.
public class RadPaneGroupRegionAdapter : RegionAdapterBase<RadPaneGroup>  
    {  
        public RadPaneGroupRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)  
            : base(regionBehaviorFactory)  
        {  
        }  
 
        protected override void Adapt(IRegion region, RadPaneGroup regionTarget)  
        {  
            region.Views.CollectionChanged += (s, e) =>  
            {  
                switch (e.Action)  
                {  
                    case NotifyCollectionChangedAction.Add:  
                        foreach (var item in e.NewItems.OfType<RadPane>())  
                        {  
                            regionTarget.Items.Add(item);  
                        }  
                        foreach (var item in e.NewItems.OfType<RadDocumentPane>())  
                        {  
                            regionTarget.Items.Add(item);  
                        }  
                        break;  
                    case NotifyCollectionChangedAction.Remove:  
                        foreach (var item in e.OldItems.OfType<RadPane>())  
                        {  
                            item.RemoveFromParent();  
                        }  
                        foreach (var item in e.OldItems.OfType<RadDocumentPane>())  
                        {  
                            item.RemoveFromParent();  
                        }  
                        break;  
                    case NotifyCollectionChangedAction.Replace:  
                        var oldItems = e.OldItems.OfType<RadPane>();  
                        var newItems = e.NewItems.OfType<RadPane>();  
                        var oldDocItems = e.OldItems.OfType<RadDocumentPane>();  
                        var newDocItems = e.NewItems.OfType<RadDocumentPane>();  
                        var newItemsEnumerator = newItems.GetEnumerator();  
                        var newDocItemsEnumerator = newDocItems.GetEnumerator();  
                        foreach (var oldItem in oldItems)  
                        {  
                            var parent = oldItem.Parent as ItemsControl;  
                            if (parent != null && parent.Items.Contains(oldItem))  
                            {  
                                parent.Items[parent.Items.IndexOf(oldItem)] = newItemsEnumerator.Current;  
                                if (!newItemsEnumerator.MoveNext())  
                                {  
                                    break;  
                                }  
                            }  
                            else 
                            {  
                                oldItem.RemoveFromParent();  
                                regionTarget.Items.Add(newItemsEnumerator.Current);  
                            }  
                        }  
                        foreach (var oldDocItem in oldDocItems)  
                        {  
                            var parent = oldDocItem.Parent as ItemsControl;  
                            if (parent != null && parent.Items.Contains(oldDocItem))  
                            {  
                                parent.Items[parent.Items.IndexOf(oldDocItem)] = newItemsEnumerator.Current;  
                                if (!newItemsEnumerator.MoveNext())  
                                {  
                                    break;  
                                }  
                            }  
                            else 
                            {  
                                oldDocItem.RemoveFromParent();  
                                regionTarget.Items.Add(newDocItemsEnumerator.Current);  
                            }  
                        }  
                        break;  
                    case NotifyCollectionChangedAction.Reset:  
                        regionTarget  
                            .EnumeratePanes()  
                            .ToList()  
                            .ForEach(p => p.RemoveFromParent());  
                        break;  
                    default:  
                        break;  
                }  
            };  
 
            foreach (var view in region.Views.OfType<RadPane>())  
            {  
                regionTarget.Items.Add(view);  
            }  
            foreach (var view in region.Views.OfType<RadDocumentPane>())  
            {  
                regionTarget.Items.Add(view);  
            }  
        }  
 
        protected override IRegion CreateRegion()  
        {  
            return new AllActiveRegion();  
        }  
    } 

Error
Timestamp: 2/23/2010 9:13:29 PM  
Message: HandlingInstanceID: 450c4eaa-c8d8-4fa9-93f2-84cb5d5dfb11  
An exception of type 'Microsoft.Practices.Composite.Modularity.ModuleInitializeException' occurred and was caught.  
------------------------------------------------------------------------------------------------------------------  
02/23/2010 16:13:29  
Type : Microsoft.Practices.Composite.Modularity.ModuleInitializeException, Microsoft.Practices.Composite, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null 
Message : An exception occurred while initializing module 'Configuration'.   
    - The exception message was: Element already has a logical parent. It must be detached from the old parent before it is attached to a new one.  
    - The Assembly that the module was trying to be loaded from was:VistaAdmin.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 
    Check the InnerException property of the exception for more information. If the exception occurred while creating an object in a DI container, you can exception.GetRootException() to help locate the root cause of the problem.   
    
Source : Microsoft.Practices.Composite  
Help link :   
ModuleName : Configuration  
Data : System.Collections.ListDictionaryInternal  
TargetSite : Void HandleModuleInitializationError(Microsoft.Practices.Composite.Modularity.ModuleInfo, System.String, System.Exception)  
Stack Trace :    at Microsoft.Practices.Composite.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 106  
   at Microsoft.Practices.Composite.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 68  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.InitializeModule(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 248  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModulesThatAreReadyForLoad() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 209  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModuleTypes(IEnumerable`1 moduleInfos) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 168  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModulesWhenAvailable() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 142  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.Run() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 71  
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.InitializeModules() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 239  
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 112  
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 69  
   at VistaAdmin.Shell.App.RunInDebugMode() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Shell\App.xaml.cs:line 48  
 
Additional Info:  
 
MachineName : GCLARK-LAPTOP  
TimeStamp : 2/23/2010 9:13:29 PM  
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35  
AppDomainName : VistaAdmin.vshost.exe  
ThreadIdentity :   
WindowsIdentity : GClark-Laptop\GClark  
    Inner Exception  
    ---------------  
    Type : System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089  
    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  
    Help link :   
    Data : System.Collections.ListDictionaryInternal  
    TargetSite : System.Windows.DependencyObject AssertPristineModelChild(System.Object)  
    Stack Trace :    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 VistaAdmin.Shell.Presentation.RadPaneGroupRegionAdapter.<>c__DisplayClass2.<Adapt>b__0(Object s, NotifyCollectionChangedEventArgs e) in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Shell\Presentation\RadPaneGroupRegionAdapter.cs:line 31  
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)  
       at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.cs:line 102  
       at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.AddAndNotify(IList items) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.Desktop.cs:line 30  
       at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.UnderlyingCollection_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.cs:line 142  
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)  
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)  
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)  
       at System.Collections.ObjectModel.Collection`1.Add(T item)  
       at Microsoft.Practices.Composite.Presentation.Regions.Region.InnerAdd(Object view, String viewName, IRegionManager scopedRegionManager) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 313  
       at Microsoft.Practices.Composite.Presentation.Regions.Region.Add(Object view, String viewName, Boolean createRegionManagerScope) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 218  
       at Microsoft.Practices.Composite.Presentation.Regions.Region.Add(Object view) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 189  
       at VistaAdmin.Configuration.Applications.ModuleController.ShowConfiguration() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Configuration\Applications\ModuleController.cs:line 48  
       at VistaAdmin.Configuration.Applications.ModuleController.Initialize() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Configuration\Applications\ModuleController.cs:line 35  
       at VistaAdmin.Configuration.Module.Initialize() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Configuration\Module.cs:line 30  
       at Microsoft.Practices.Composite.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 64  
 
 
Category: General  
Priority: 0  
EventId: 100  
Severity: Error  
Title:Enterprise Library Exception Handling  
Machine: GCLARK-LAPTOP  
Application Domain: VistaAdmin.vshost.exe  
Process Id: 4532  
Process Name: C:\Users\GClark\Documents\Visual Studio 2008\Output\Debug\VistaAdmin.vshost.exe  
Win32 Thread Id: 1312  
Thread Name:   
Extended Properties:  

0
Miroslav Nedyalkov
Telerik team
answered on 24 Feb 2010, 08:55 AM
Hi Garry,

 As the RadDocumentPane inherits from the RadPane this line of code:

var view in region.Views.OfType<RadDocumentPane>()

will return a subset of the result of the following line:

var view in region.Views.OfType<RadPane>()

So you will add all document panes twice - this causes the exception. As far as I know the region adapter in the blog post should work fine with RadDocumentPanes. I tried the sample application from the blog post and it forks fine with DocumentPanes.

Could you please share more details about the problem you are experiencing if you don't change the custom region adapter, suggested in the blog post?

Sincerely yours,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Garry
Top achievements
Rank 1
answered on 24 Feb 2010, 04:54 PM
Miroslav,
OK I have changed my RegionAdapter back to the way it was and removed all of the RadDocumentPane code. The reason I added the code was because of the error below that I now get when I try and add this module to the DocumentHost region. The error is internal to Microsoft.Practices.Composite and I can't seem to find the cause of it. I thought it was due to the fact that it didn't know how to deal with the RadDocumentPane object, but according to your last post that is not the case. Below I have attached the view xaml for my module I am trying to add and the xaml from the shell/region I am trying to add it to.

Also just to note that if I add this to a standalone PaneGroup rather than a PaneGroup inside of a DocumentHost everything works fine. It defintely has something to do with the way I am trying to use the DocumentHost.

Error
Timestamp: 2/24/2010 4:41:09 PM  
Message: HandlingInstanceID: 1d1c2b42-be85-422c-9d05-6cf5df477a25  
An exception of type 'Microsoft.Practices.Composite.Modularity.ModuleInitializeException' occurred and was caught.  
------------------------------------------------------------------------------------------------------------------  
02/24/2010 11:41:09  
Type : Microsoft.Practices.Composite.Modularity.ModuleInitializeException, Microsoft.Practices.Composite, Version=2.0.0.0, Culture=neutralPublicKeyToken=null 
Message : An exception occurred while initializing module 'Configuration'.   
    - The exception message was: Object reference not set to an instance of an object.  
    - The Assembly that the module was trying to be loaded from was:VistaAdmin.Configuration, Version=1.0.0.0, Culture=neutralPublicKeyToken=null 
    Check the InnerException property of the exception for more information. If the exception occurred while creating an object in a DI container, you can exception.GetRootException() to help locate the root cause of the problem.   
    
Source : Microsoft.Practices.Composite  
Help link :   
ModuleName : Configuration  
Data : System.Collections.ListDictionaryInternal  
TargetSite : Void HandleModuleInitializationError(Microsoft.Practices.Composite.Modularity.ModuleInfo, System.String, System.Exception)  
Stack Trace :    at Microsoft.Practices.Composite.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 106  
   at Microsoft.Practices.Composite.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 68  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.InitializeModule(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 248  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModulesThatAreReadyForLoad() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 209  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModuleTypes(IEnumerable`1 moduleInfos) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 168  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.LoadModulesWhenAvailable() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 142  
   at Microsoft.Practices.Composite.Modularity.ModuleManager.Run() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleManager.cs:line 71  
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.InitializeModules() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 239  
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 112  
   at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run() in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 69  
   at VistaAdmin.Shell.App.RunInDebugMode() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Shell\App.xaml.cs:line 48  
 
Additional Info:  
 
MachineName : GCLARK-LAPTOP  
TimeStamp : 2/24/2010 4:41:09 PM  
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutralPublicKeyToken=31bf3856ad364e35 
AppDomainName : VistaAdmin.vshost.exe  
ThreadIdentity :   
WindowsIdentity : GClark-Laptop\GClark  
    Inner Exception  
    ---------------  
    Type : System.NullReferenceException, mscorlib, Version=2.0.0.0, Culture=neutralPublicKeyToken=b77a5c561934e089 
    Message : Object reference not set to an instance of an object.  
    Source : VistaAdmin.PTFS  
    Help link :   
    Data : System.Collections.ListDictionaryInternal  
    TargetSite : VistaAdmin.Infrastructure.Documents.Document GetActiveDocument()  
    Stack Trace :    at VistaAdmin.PTFS.Applications.DocumentController.GetActiveDocument() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.PTFS\Applications\DocumentController.cs:line 36  
       at VistaAdmin.Infrastructure.Module.Applications.DocumentManager.ActiveViewsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Infrastructure.Module\Applications\DocumentManager.cs:line 181  
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)  
       at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.cs:line 102  
       at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.AddAndNotify(IList items) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.Desktop.cs:line 30  
       at Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.UnderlyingCollection_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\ViewsCollection.cs:line 142  
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)  
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)  
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)  
       at System.Collections.ObjectModel.Collection`1.Add(T item)  
       at Microsoft.Practices.Composite.Presentation.Regions.Region.InnerAdd(Object view, String viewName, IRegionManager scopedRegionManager) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 313  
       at Microsoft.Practices.Composite.Presentation.Regions.Region.Add(Object view, String viewName, Boolean createRegionManagerScope) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 218  
       at Microsoft.Practices.Composite.Presentation.Regions.Region.Add(Object view) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite.Presentation\Regions\Region.cs:line 189  
       at VistaAdmin.Configuration.Applications.ModuleController.ShowConfiguration() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Configuration\Applications\ModuleController.cs:line 48  
       at VistaAdmin.Configuration.Applications.ModuleController.Initialize() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Configuration\Applications\ModuleController.cs:line 35  
       at VistaAdmin.Configuration.Module.Initialize() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\VistaAdmin\VistaAdmin.Configuration\Module.cs:line 30  
       at Microsoft.Practices.Composite.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo) in D:\Application Installs\Composite Controls 2009\CAL\Desktop\Composite\Modularity\ModuleInitializer.cs:line 64  
 
 
Category: General  
Priority: 0  
EventId: 100  
Severity: Error  
Title:Enterprise Library Exception Handling  
Machine: GCLARK-LAPTOP  
Application Domain: VistaAdmin.vshost.exe  
Process Id: 1604  
Process Name: C:\Users\GClark\Documents\Visual Studio 2008\Output\Debug\VistaAdmin.vshost.exe  
Win32 Thread Id: 2912  
Thread Name:   
Extended Properties:  

Shell Region Xaml (Does not work when added here)
<radDock:RadDocking.DocumentHost> 
                    <radDock:RadSplitContainer> 
                        <radDock:RadPaneGroup x:Name="DocGroup" prismrgn:RegionManager.RegionName="{x:Static i:RegionNames.MainRegion}">  
                              
                        </radDock:RadPaneGroup> 
                    </radDock:RadSplitContainer> 
                </radDock:RadDocking.DocumentHost> 

Shell Region Xaml (Does work when added here)
<radDock:RadSplitContainer Width="Auto" 
                    Name="LeftContainer" InitialPosition="DockedLeft" MinWidth="200">  
                    <radDock:RadPaneGroup x:Name="Group1" prismrgn:RegionManager.RegionName="{x:Static i:RegionNames.LeftRegion}">  
                    </radDock:RadPaneGroup> 
                </radDock:RadSplitContainer> 


Module View Xaml
<telerikDocking:RadDocumentPane x:Class="VistaAdmin.Configuration.Presentation.ConfigurationView" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:v="clr-namespace:VistaAdmin.Configuration.Presentation" 
    xmlns:p="clr-namespace:VistaAdmin.Configuration.Properties" 
    xmlns:telerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking" 
    Header="{Binding HeaderInfo}">  
    <telerikDocking:RadDocumentPane.Content> 
        <DockPanel> 
            <StackPanel DockPanel.Dock="Top">  
                <!--<ToolBar> 
               <Button x:Name="installPTFButton" ToolTip="{x:Static p:Resources.Open}" Command="{Binding InstallPTFCommand}">  
                    <Image Source="../Resources/open.png" Width="16" Height="16"/>  
                </Button> 
                <Button x:Name="ptfDetailButton" ToolTip="{x:Static p:Resources.Detail}" Command="{Binding PTFDetailCommand}">  
                    <Image Source="../Resources/details.png" Width="16" Height="16"/>  
                </Button> 
            </ToolBar>--> 
            </StackPanel> 
        </DockPanel> 
    </telerikDocking:RadDocumentPane.Content> 
</telerikDocking:RadDocumentPane> 
 
0
Miroslav Nedyalkov
Telerik team
answered on 25 Feb 2010, 04:36 PM
Hello Garry,

 This error seems very odd. It seems that there is another problem somewhere in your code as the example on the blog post does the same thing as you do (I ported it to WPF and updated the blog post).

 Could you please send us a sample project that reproduces the problem - this would be very helpful?

Best wishes,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Garry
Top achievements
Rank 1
answered on 01 Mar 2010, 05:31 PM
Miroslav,
I found the root of my issue and you were correct it was something internal to my code. I am still not quite sure how to fix it, but I atleast found the module causing the issue and as long as I load it last then all my module troubles go away.

Thanks for your help with this!
0
Miroslav Nedyalkov
Telerik team
answered on 01 Mar 2010, 05:41 PM
Hello Garry,

 I'm happy to hear that you found the source of the problem.

If you have further questions we will be happy to assist you with them.

Best wishes,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Docking
Asked by
Garry
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Garry
Top achievements
Rank 1
Valentin.Stoychev
Telerik team
Share this question
or