I've got a tab control with a region attached to it and I've also got a content control inside my tab controls content with another region.
The problem I'm having is - if I call RegisterViewWithRegion it adds the view to the region no problem (first time that is, get issues if you swap tabs). But this isn't very flexible and I'm looking for a better way to do that.
When I look inside IRegionManager.Regions as well - I can only see the two top level regions. I cant see my sub region TabContentRegion. 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 the 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 I've been using to actually display the view in the 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 - it's a bit janky and doesn't quite work. Any ideas what I'm doing wrong?
Thanks for any help!