I have a tab control with an area attached to it, and I also have a content control inside my tab control with a different region.
The problem I am facing is that if I call RegisterViewWithRegion, it does not add the view to the region without problems (the first time there are problems if you change the tabs). But this is not very flexible, and I am looking for the best way to do this.
When I look at IRegionManager.Regions, I can only see two top-level areas. I can not see my TabContentRegion subregion. Is there a way to register this, so I can just work in the usual way with adding views and activating them?
<TabControl TabStripPlacement="Left" Width="Auto" Height="Auto" cal:RegionManager.RegionName="TabRegion" Name="TabRegion" SelectedItem="{Binding SelectedTab}"> <TabControl.ContentTemplate> <DataTemplate> <ContentControls:TransitionContentControl cal:RegionManager.RegionName="TabContentRegion" /> </DataTemplate> </TabControl.ContentTemplate> </TabControl>
This code adds views to the TabRegion
public void Load() { IConfigurationDetailsPresentationModel convDetailsView1 = this.Container.Resolve<IConfigurationDetailsPresentationModel>(); IRegionManager manager = this.Container.Resolve<IRegionManager>(); manager.RegisterViewWithRegion("TabRegion", () => convDetailsView1); IConversationDetailsPresentationModel conversationDetails = this.Container.Resolve<IConversationDetailsPresentationModel>(); manager.RegisterViewWithRegion("TabRegion", () => conversationDetails); }
Then this is the code that I used to actually display the view in TabContentRegion
public IPresentationModel SelectedTab { get { return _selectedTab; } set { _selectedTab = value; IRegionManager service = this.Container.Resolve<IRegionManager>(); if (service != null) { service.RegisterViewWithRegion( "TabContentRegion", () => _selectedTab.View); } } }
As you can see, this is a bit chatty and not quite working. Any ideas what I'm doing wrong?
Thanks for any help!
source share