我在下面有XAML:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TabControl Margin="10" TabStripPlacement="Left" BorderBrush="gray">
<TabControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Height" Value="40" />
<Setter Property="Border.BorderBrush" Value="gray" />
<Setter Property="Border.Background" Value="lightgray" />
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="6,0,0,6" />
<Setter Property="Margin" Value="0,1.5" />
</Style>
</Style.Resources>
</Style>
</TabControl.Resources>
<TabItem Header="Tab 1">
Conten1
</TabItem>
<TabItem Header="Tab 2">
Content2
</TabItem>
<TabItem Header="Tab 3">
Content2
</TabItem>
</TabControl>
</Border>
我需要在上面的xaml中更改哪些内容,使TabItem顶部和底部边框与制表符控件边框对齐? 我希望它看起来好像顶部标签项控件和顶部tabcontrol边框形成一行。与底部边框相同。
答案 0 :(得分:0)
尝试以下代码。几乎没有变化。希望它有所帮助。
<TabControl Margin="10" TabStripPlacement="Left" HorizontalContentAlignment="Left" BorderBrush="gray">
<TabControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Border.BorderBrush" Value="gray" />
<Setter Property="Border.Background" Value="lightgray" />
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="6,0,0,6" />
<!--<Setter Property="Margin" Value="0,1.5" />-->
</Style>
</Style.Resources>
</Style>
</TabControl.Resources>
<TabItem Header="Tab 1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
Conten1
</TabItem>
<TabItem Header="Tab 2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
Content2
</TabItem>
<TabItem Header="Tab 3" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
Content2
</TabItem>
</TabControl>