简体   繁体   English

WPF TabControl如何在选择tabItem时删除行

[英]WPF TabControl How to remove line when tabItem is selected

Designers hate developers that why they create so weard designs!)) So my task is to create xaml UI from psd file. 设计师讨厌开发人员,为什么他们要创建如此破旧的设计!))所以我的任务是从psd文件创建xaml UI。 I'm finishing it but I don't know how to remove line in selected tabItem. 我正在完成它,但是我不知道如何删除所选tabItem中的行。 Lood at the pictures. 懒洋洋地看图片。

That's what I need to get. 那就是我需要得到的。 在此处输入图片说明

That's what I got. 那就是我得到的。 在此处输入图片说明

How can I remove this this line? 如何删除此行? Is It possible without hard-coding? 没有硬编码就可以吗? Here's code of my tab control. 这是我的标签控件的代码。

     <TabControl.Resources>
            <Style TargetType="TabControl">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabControl}">
                            <Grid KeyboardNavigation.TabNavigation="Local">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Border
                                    Name="Border"
                                    Grid.Row="0"
                                    BorderBrush="{StaticResource SolidBrush_Blue}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    KeyboardNavigation.TabNavigation="Local"
                                    KeyboardNavigation.DirectionalNavigation="Contained"
                                    KeyboardNavigation.TabIndex="2" >
                                    <ContentPresenter
                                        Name="PART_SelectedContentHost"
                                        ContentSource="SelectedContent">
                                    </ContentPresenter>
                                </Border>
                                <TabPanel
                                    Name="HeaderPanel"
                                    Grid.Row="1"
                                    Panel.ZIndex="1"
                                    HorizontalAlignment="Center"
                                    IsItemsHost="True"
                                    KeyboardNavigation.TabIndex="1"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <!-- SimpleStyles: TabItem -->
            <Style TargetType="{x:Type TabItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <Grid
                                x:Name="grid">
                                <Border
                                    Name="Border"
                                    Margin="5,0,5,0"
                                    Padding="30 15 30 15"
                                    CornerRadius="0 0 3 3"
                                    BorderBrush="{StaticResource SolidBrush_Blue}"
                                    BorderThickness="2 0 2 2" >
                                    <ContentPresenter
                                        x:Name="contentPresenter"
                                        VerticalAlignment="Center"
                                        ContentSource="Header"
                                        TextBlock.Foreground="White"
                                        TextBlock.FontFamily="{StaticResource FontFamilyRegular}"
                                        RecognizesAccessKey="True">
                                    </ContentPresenter>
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter TargetName="Border"
                                            Property="Background"
                                            Value="White" />
                                    <Setter TargetName="contentPresenter"
                                            Property="TextBlock.FontFamily"
                                            Value="{StaticResource FontFamilyBold}"/>
                                    <Setter TargetName="contentPresenter"
                                            Property="TextBlock.Foreground"
                                            Value="{StaticResource SolidBrush_Blue}"/>
                                </Trigger>
                                <Trigger Property="IsSelected" Value="False">
                                    <Setter TargetName="Border"
                                            Property="Background" 
                                            Value="{StaticResource SolidBrush_Blue}" />
                                    <Setter TargetName="contentPresenter"
                                            Property="TextBlock.Background"
                                            Value="White"/>
                                    <Setter TargetName="contentPresenter"
                                            Property="TextBlock.FontFamily"
                                            Value="{StaticResource FontFamilyRegular}"/>
                                    <Setter TargetName="contentPresenter" 
                                            Property="TextBlock.Foreground" 
                                            Value="White"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </TabControl.Resources>

in TabItem Template for border Border set Margin="5,-1,5,0" . 在TabItem Template中的Border设置Margin="5,-1,5,0" The border will move up and hide a borderline of TabControl with default thickness of 1 边框将向上移动并隐藏默认值为1的TabControl的边界线

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM