代码下载:SL3TabControl_new.zip
关键代码如下:
<Controls:TabControl Regions:RegionManager.RegionName="TabRegion"
Width="Auto" Height="Auto" Margin="0,5,0,0" HorizontalAlignment="Stretch">
<Regions:TabControlRegionAdapter.ItemContainerStyle>
<Style TargetType="Controls:TabItem">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding HeaderInfo}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Regions:TabControlRegionAdapter.ItemContainerStyle>
</Controls:TabControl>
public void Initialize()
{
this.RegisterViewsAndServices();
for (int i = 0; i < 5; i++)
this.regionManager.Regions["TabRegion"].Add(this.container.Resolve<CView>(), "C" + i.ToString(), true);
}
public class CViewModel
{
protected readonly IUnityContainer container;
protected readonly IRegionManager regionManager;
public CViewModel(IRegionManager regionManager, IUnityContainer container)
{
this.regionManager = regionManager;
this.container = container;
IRegion tabRegion = regionManager.Regions["TabRegion"];
object existingView = tabRegion.GetView("C");
}
public CView View { get; set; }
public static string HeaderInfo
{
get { return "bjq"; }
}
}