Multiple Shells ( SL 3 Navigation) and Exception

Topics: Prism v2 - Silverlight 2
Apr 17, 2009 at 4:08 AM
Went through an excellent  blog

http://blogs.southworks.net/mconverti/2009/04/12/how-to-integrate-a-prism-v2-application-with-the-silverlight-3-navigation-framework/

However when i add a region to each of the Navigation pages it goes pop when i Navigate away and Navigate back , it seems that DelayedRegionCreation is firing and trying to add the region again. This is not a Navigation problem.

I have tried

AddModuleUriMappings();

this.regionManager.Regions["LinkRegion"].Add(new DiggModuleLink());
IRegion region = new AllActiveRegion();
regionManager.Regions.Add("ResultsRegion", region);

region.Add(container.Resolve<DiggSearchResultsView>(), "DiggSearchResultsView", true);


and this as variations

this.container.RegisterType<IDiggService, DiggService>(new ContainerControlledLifetimeManager());

AddModuleUriMappings();

this.regionManager.Regions["LinkRegion"].Add(new DiggModuleLink());

IRegion region = new AllActiveRegion();
regionManager.Regions.Add("ResultsRegion", region);

region.Add(container.Resolve<DiggSearchResultsView>(), "DiggSearchResultsView", true);

The link region which is registered on the Shell works but the regions in the View ( or Navigation Page) get  added , then the delayedRegionCreation tried to  re add them and it goes pop, any hints or clues ?
Apr 17, 2009 at 4:26 AM
I am having similar problems with regard to view injection in SL3 ChildWindows.  Setting the attached RegionName property on the control in xaml does not appear to get registered with the RegionManager.  I also tried a similar approach whereby I set the attached property in the code-behind and still the same problem when trying to retrieve a region reference in my viewModel--RegionManager does not contain that Region Name.  Incidently the view discovery approach works fine regardless of the parent container type (ie. ChildWindow), however I prefer view injection in some scenarios and have been banging my head on this for a few hours now. 

I also implemented Marianos approach to prism navigation with SL3, however his implementation strategy is not the problem, at least in my case, as the problem for me occurred well before.

Sorry I cant be of any help, but I figured this is a good spot to post a similar issue:)
Apr 17, 2009 at 8:05 AM
Edited Apr 17, 2009 at 8:17 AM
The plot thickens i have simplified it a bit  and it apears the SearchRegion doesnt work but the Results region does . I have made Search region a tab control and no change.

<ContentControl Regions:RegionManager.RegionName="SearchRegion" Grid.Row="0" Margin="2" />

<controls:TabControl Regions:RegionManager.RegionName="ResultsRegion" Grid.Row="1" Margin="3" >
<Regions:TabControlRegionAdapter.ItemContainerStyle>
<Style TargetType="controls:TabItem">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding HeaderInfo}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Regions:TabControlRegionAdapter.ItemContainerStyle>
</controls:TabControl>

in initialize of the module

note local is a new RegionManager ( unattached to the parent )

local.RegisterViewWithRegion("SearchRegion", typeof(SearchView));
local.RegisterViewWithRegion("ResultsRegion", typeof(DiggSearchResultsView));


Note it shows ok the first time but when Navigation shows it a 2nd time it shows a Region already created error. Im curious though why the Tab control works.