Add PRISM Region Manager In Existing Navigation Window
- by Nate Noonen
We have a "legacy" WPF applicaton that is based on a NavigationWindow. The NavigationWindow has a fairly large ControlTemplate that houses a ContentPresenter as so:
<ControlTemplate>
....snip...
<ContentPresenter x:Name="PART_NavWinCP" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
.....snip....
</ControlTemplate>
What we want to do is use that ContentPresenter as the first tab and dynamically add other tabs at run time. Like this:
<ControlTemplate>
....snip...
<TabControl Background="Transparent" cal:RegionManager.RegionName="MainRegion" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<TabItem Header="Nav Window Content">
<ContentPresenter x:Name="PART_NavWinCP" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</TabItem>
</TabControl>
.....snip....
</ControlTemplate>
Then our Modules grab the RegionName and insert their content dynamically. The issue seems to be that the PRISM region manager doesn't like that our code is in a ContentTemplate and cannot resolve the region. I have tried updating the RegionManager, adding the Region dynamically, just having a root tab control without the ContentPresenter, but I cannot get this to work. Any ideas?