Region defined in Style?

Topics: Prism v1, Prism v2 - Silverlight 2, Prism v2 - WPF 3.5
Jan 22, 2009 at 12:43 AM
Hi all,

I have a requirement whereby I have to divide a tabcontrol into two sections, the first section holds tabitem views and the second section displays help views.  I'm using a style which has a region defined for the Help section using a grid and grid splitter however at runtime the RegionManager does not have the Help region in the region collection.  My question is this... is it not possible to define a region in a style??

My style for the tab control looks like this:



<Style TargetType="{x:Type TabControl}">




<Setter Property="Template">








<ControlTemplate TargetType="{x:Type TabControl}">












<RowDefinition Height="Auto"/>




<RowDefinition Height="*"/>























Background="Transparent" />
















CornerRadius="12, 12, 12, 12">












<ColumnDefinition Width="*" />




<ColumnDefinition Width="3" />




<ColumnDefinition Width="147" />








<Border Margin="10,5,10,10" Grid.Row="1" Grid.Column="0" CornerRadius="4,4,4,4" BorderBrush="#193441" Background="{DynamicResource SolidFocusBrush}" BorderThickness="2,2,2,2">




<ContentPresenter ContentSource="SelectedContent" />








<GridSplitter Grid.Column="1" Grid.Row="1" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent" />




<Border Margin="0,5,10,10" Grid.Row="1" Grid.Column="2" CornerRadius="4,4,4,4" BorderBrush="#193441" Background="#FFFFFF" BorderThickness="2,2,2,2">




<ItemsControl x:Name="HelpRegionWorkspace" cal:RegionManager.RegionName="{x:Static inf:RegionNames.HelpRegion}"/>


































Jan 22, 2009 at 3:58 PM



Generally, the views are the ones that define regions and all the regions mechanism was made with that consideration. Styles are usually modified/replaced very frequently by different people (designers using Blend for example) and it is not a safe place to define a region (one minor change to the region definition in a style could impact the whole application).


I would suggest you to use two different controls, one TabControl to hold all your TabItem views, and a separated ItemsControl / ContentControl that defines the HelpRegion (and apply the styles to them). Once defined, you can then modify their templates.


Please let me know if this helps.


Mariano Converti

Jan 22, 2009 at 10:26 PM

Thanks Mariano

Initially I had it set up the way you suggested however our UI design requirement was changed so the help region appears embedded in the tabcontrol as apposed to being placed next to the tabcontrol.  The only way I could think to do this without creating a custom tabcontrol was to do it via template/style.  Do you have any suggestions as to how I could achieve this using some other approach?