tabcontrol - wpf删除选项卡控件选项卡下的行

  显示原文与译文双语对照的内容
56 4

使用 xaml ( wpf ),我试图将选项卡控件下的行作为"插图"显示,这样它就会看起来像"插图b":

插图

http://www.arulerforwindows.com/images/peskylinea.png

插图B

http://www.arulerforwindows.com/images/peskylineb.png

当我定义选项卡项,但似乎附加到选项卡控件上时,BorderThickness或者Tab控件不会产生所需的结果。

我需要在透明背景上做这个,但是实体填充 rectangle 不能用来掩盖问题。

下面是代码:

<!--Tab Control-->
<Style TargetType="{x:Type TabControl}">
 <Setter Property="OverridesDefaultStyle" Value="True"/>
 <Setter Property="SnapsToDevicePixels" Value="True"/>
 <Setter Property="Template">
 <Setter.Value>
 <ControlTemplate TargetType="{x:Type TabControl}">
 <Grid KeyboardNavigation.TabNavigation="Local">
 <Grid.RowDefinitions>
 <RowDefinition Height="Auto"/>
 <RowDefinition Height="*"/>
 </Grid.RowDefinitions>
 <TabPanel Name="HeaderPanel" Grid.Row="0" Panel.ZIndex="1" Margin="0,0,0,-1" IsItemsHost="True" KeyboardNavigation.TabIndex="1" Background="Transparent"/>
 <Border 
 Name="Border" 
 Grid.Row="1" 
 Background="{StaticResource WindowBackgroundBrush}" 
 BorderBrush="{StaticResource DefaultSystemBrush}" 
 BorderThickness="1,1,1,1" 
 Margin="0,0,0,0"
 CornerRadius="4" 
 KeyboardNavigation.TabNavigation="Local"
 KeyboardNavigation.DirectionalNavigation="Contained"
 KeyboardNavigation.TabIndex="2"> 
 <ContentPresenter 
 Name="PART_SelectedContentHost"
 Margin="4"
 ContentSource="SelectedContent"/>
 </Border> 
 </Grid>
 <ControlTemplate.Triggers>
 <Trigger Property="IsEnabled" Value="False">
 <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
 <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}"/>
 </Trigger>
 <Trigger Property="IsEnabled" Value="False">
 <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
 <Setter Property="BorderBrush" TargetName="Border" Value="{StaticResource DisabledBorderBrush}"/>
 </Trigger>
 </ControlTemplate.Triggers>
 </ControlTemplate>
 </Setter.Value>
 </Setter>
</Style>
<Style TargetType="{x:Type TabItem}">
 <Setter Property="Template">
 <Setter.Value>
 <ControlTemplate TargetType="{x:Type TabItem}">
 <Grid>
 <Border Name="Border" Background="Transparent" BorderBrush="{StaticResource DefaultSystemBrush}" BorderThickness="1,1,1,1" CornerRadius="6,6,0,0">
 <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" Margin="12,2,12,2"/>
 </Border>
 </Grid>
 <ControlTemplate.Triggers>
 <Trigger Property="IsSelected" Value="True">
 <Setter Property="Panel.ZIndex" Value="100"/>
 <Setter TargetName="Border" Property="Background" Value="Transparent"/>
 <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0"/>
 </Trigger>
 <Trigger Property="IsSelected" Value="False">
 <Setter TargetName="Border" Property="Background" Value="LightGray"/>
 <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0"/>
 </Trigger>
 </ControlTemplate.Triggers>
 </ControlTemplate>
 </Setter.Value>
 </Setter>
</Style>

请提前致谢

罗勃

时间:原作者:0个回答

74 3

使用 ShowMeTheTemplate,我发现了一部分风格,它在,上。在默认控件模板中有许多,如果你重写它,你可以能会感兴趣。

<MultiTrigger>
 <MultiTrigger.Conditions>
 <Condition Property="Selector.IsSelected">
 <Condition.Value>
 <s:Boolean>True</s:Boolean>
 </Condition.Value>
 </Condition>
 <Condition Property="TabItem.TabStripPlacement" Value="{x:Static Dock.Top}"/>
 </MultiTrigger.Conditions>
 <Setter Property="FrameworkElement.Margin">
 <Setter.Value>
 <Thickness>-2,-2,-2,-1</Thickness>
 </Setter.Value>
 </Setter>
</MultiTrigger>
原作者:
...