Regions and Page based Navigation

Topics: Prism v2 - WPF 3.5
Sep 22, 2009 at 2:23 PM

Hi, I'm trying to make a TabControl as a Region with Frame inside every TabItem, that holds Pages. More or less just luke IE 8.0 looks like:

		<Frame Source={Binding ??}/>

I started with ControlTemplate of TabControl...
<Style x:Key="WebTabControlStyle" TargetType="{x:Type TabControl}">
	<Setter Property="Template">
			<ControlTemplate TargetType="{x:Type TabControl}">
				<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
					<ColumnDefinition x:Name="ColumnDefinition0"/>
					<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
					<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
					<RowDefinition x:Name="RowDefinition1" Height="*"/></Grid.RowDefinitions>
				<Frame HorizontalAlignment="Stretch"  VerticalAlignment="Stretch"  Source="{TemplateBinding SelectedContent}"/>
Yet it doesn't work. I tryied to use ContentPresenter, but then it failed - Pages can't be hosted in contentcontrol. 
Maybe you could give me advice, how to solve this problem. Should I make a RegionAdapter or how should I change RegionManager somehow? Any suggestions?
Thanks in adv.
Sep 25, 2009 at 10:10 PM


As you said, Pages are only hosted in Frame controls. By default TabControls do not host Pages inside their TabItem children, so a region adapter would not be enough (because the adapter would only be able to add items to the TabControl but not change how TabItems are composed).

Another blocking point is that Silverlight 3 Navigation is not fully functional with Prism-v2, you can read more about that here.

If you still want to customize the TabControl so TabItems have Frame as children, you can might get a more detailed answer in the Silverlight forums, as it is specialized in Silverlight.

Please let me know if this helps.

Damian Schenkelman

Sep 26, 2009 at 1:08 PM
Edited Sep 26, 2009 at 1:13 PM


Thanks for your post. It will be helpfull as this functionality is going to be in 2 target versions WPF and Silverlight.

I've solved the problem (temporarily), maybe not in very elegant way, yet it works. I've develop some extension methods to IRegionManager. For eg.

IRegionManager.RegisterViewWithRegion(string regionName, Page page);

And then I add a frame and Navigate to page imidietly. So everyware where there should be access to a content I make another extension method. This is quite strate forward, yet it is hard to customize the appearance of frame, because it is created in C# code. And secondly it's wrong that creating the frame is in an extension method to IRegionManager which is rater lib problem, and the apperance is not separeted from lib...