如图所示:
要做到这种效果,可以对TabControl的Style进行重写,上代码:
1 <Style x:Key="TabControlStyle" TargetType="{x:Type TabControl}"> 2 <Setter Property="Template"> 3 <Setter.Value> 4 <ControlTemplate TargetType="{x:Type TabControl}"> 5 <Grid Background="Transparent"> 6 <Grid.RowDefinitions> 7 <RowDefinition Height="Auto"/> 8 <RowDefinition Height="*"/> 9 </Grid.RowDefinitions> 10 <Border BorderBrush="Transparent" BorderThickness="0 0 0 0"> 11 <!--<TabPanel IsItemsHost="True"/>--> 12 <UniformGrid Rows="1" IsItemsHost="True"></UniformGrid> 13 </Border> 14 <Border Grid.Row="1" 15 BorderBrush="Transparent" 16 Padding="0" 17 BorderThickness="0" Background="{TemplateBinding Background}"> 18 <ContentPresenter ContentSource="SelectedContent" Name="PART_SelectedContentHost"/> 19 </Border> 20 </Grid> 21 22 </ControlTemplate> 23 </Setter.Value> 24 </Setter> 25 </Style>
Border 标签中,将TabPanel换为UniformGrid,要注意的一点是:这个Rows="1",必须设置。
感谢您的阅读。