Remove view from region ArgumentException and 2 more questions

Topics: Prism v4 - Silverlight 4
Feb 7, 2011 at 11:30 PM
Edited Feb 8, 2011 at 9:16 AM

Hello.

I am new to Prism, and I am trying to integrate it in my current application. I have some issues with it, so, dear community members, I need help :)

Scenario.

Silverlight4+Prism4+MEF(included in sl4)+TelerikDocking with custom RegionAdapter (I think that my issues are not on telerik controls side). 2 Regions – one for navigation and one for tabs in docking control. 2 modules:1. ModuleCOnlyView – module with one View, registered with RegisterViewWithRegion() method2. ModuleBButtonPlusView – module with button and view.

I prepared test project, you can download it here http://cid-b16922e1fb07cd95.office.live.com/self.aspx/.Public/Prism4MefTelerikDocking.zip

I have deleted references for telerik controls, but you can download trial from their site and reference Telerik.Windows.Controls, Telerik.Windows.Controls.Docking and Telerik.Windows.Controls.Navigation in Prism4MefTelerikDocking project.

All my question and issues have //NOTE: marks in code.

1. When I click on button ModuleB_Button – new tab added to dock control. When I try to close that tab (with x button) exception is being thrown, but view is actually removed! (I have found similar problem http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=242932 but no answer). Exception: ArgumentException: The region does not contain the specified view. Parameter name: view. Look at Note 1 in code.

2. If I navigate to region with RegionManager.RequestNavigate(…) (ModuleBButtonPlusViewNavigationItem.xaml.cs) then I can’t get view with the GetView(string viewName) method (note 2). I know, that I need to use  this.RegionManager.Regions["…"].Add(…); method to access view by its name, but in this case NavigationService.Navigating event won’t fire (I need it to implement some specific logic there). Is there any elegant way to retrieve specific view by name on the Module side?

3. Note 3. In IViewCollection CollectionChanged event with Reset action fires immediately after CollectionChanged event with Add action. Why?

Thanks!