Thursday, March 11, 2010

How to set the TabItem Header in a Silverlight TabControl using Prism

In this piece of XAML it's assumed that the view being placed into the TabControl region has it's DataContext bound to a view model containing a HeaderInfo property.

For the complete example see ViewInjectionComposition quick start and have a look at the EmployeeDetailsView.

The trick to displaying the header is to override the HeaderTemplate property on the TabItem using a style.

<Style TargetType="controls:TabItem" x:Key="TabItemStyle">
<Setter Property="HeaderTemplate">
<TextBlock Text="{Binding HeaderInfo}" />

<Grid x:Name="LayoutRoot">
Regions:TabControlRegionAdapter.ItemContainerStyle="{StaticResource TabItemStyle}"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.