zoukankan      html  css  js  c++  java
  • 一个简单的TabItem样式。

    分享一个以前项目中用到的简单的TabItem样式。

    效果图如下:

            <SolidColorBrush x:Key="TabItemDisabledBackground" Color="#F4F4F4"/>
            <SolidColorBrush x:Key="TabItemDisabledBorderBrush" Color="#FFC9C7BA"/>
    
            <Style  TargetType="{x:Type TabItem}">
                <!--<Setter Property="FocusVisualStyle" Value="{x:null}"/>-->
                <Setter Property="Foreground" Value="#333333"/>
                <Setter Property="FontSize" Value="16"/>
                <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
                <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <Grid SnapsToDevicePixels="true" Height="40" MinWidth="110">
                                <Path Margin="0 0 0 -12" x:Name="PATH" Visibility="Collapsed" Data="M0.5,0.5 L109.5,0.5 109.5,39.5 64,40 57,51 49,40 0.5,39.5 z" Fill="#FF0FAF46"  Height="51.5"  Stretch="Fill" Stroke="Transparent"  Width="110"/>
                                <Border x:Name="Bd" Background="#dfe9f6">
                                    <ContentPresenter Margin="5 0 5 0" x:Name="Content" ContentSource="Header" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                        <Condition Property="IsSelected" Value="true"/>
                                        <Condition Property="TabStripPlacement" Value="Top"/>
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Visibility" Value="visible" TargetName="PATH"/>
                                    <Setter Property="Foreground" Value="White"></Setter>
                                    <Setter Property="Background" Value="#FF0FAF46" TargetName="Bd"/>
                                </MultiTrigger>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItemDisabledBackground}"/>
                                    <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource TabItemDisabledBorderBrush}"/>
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    

      这里只实现了标签方向在Top的实现,其它动画或者显示效果都是可以随意增加的!

  • 相关阅读:
    网络技术全方位解析之三:RAID
    Linux系统安全隐患及加强安全管理的方法
    Silverlight 程序架构
    (转载)Qt:给QLineEdit加上一个搜索按钮
    (转载)StarUML启动时候出现"System Error. Code:1722. RPC服务器不可用."错误的解决办法
    (转载)starUML connect elements exactly
    (转载)Qt:拖拽图片到QLabel上并显示
    (转载)Qt:禁止qDebug的输出
    (转载)葱的营养价值和食用功效
    (转载)Qwt的安装与使用
  • 原文地址:https://www.cnblogs.com/yk250/p/5652928.html
Copyright © 2011-2022 走看看