wenxiangchao
4 天以前 2e889843b4c171f2d6ad8e0d53084040703d11f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/HMI.UI;component/Style/colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>
 
    <Style x:Key="tabItemStyle" TargetType="TabItem">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate x:Name="ct" TargetType="TabItem">
                    <Border x:Name="templateRoot" BorderThickness="0,0,0,3" Padding="3,3,3,0" 
                    BorderBrush="Transparent">
                        <Label x:Name="txt" Visibility="Visible" BorderThickness="0" 
                        VerticalContentAlignment="Center" 
                        HorizontalAlignment="Left"
                        Content="{TemplateBinding Header}" ToolTip="{TemplateBinding Header}" 
                        Foreground="{TemplateBinding Foreground}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=TabStripPlacement}" Value="Left">
                            <Setter Property="BorderThickness" TargetName="templateRoot" Value="0,0,3,0"/>
                            <Setter Property="Padding" TargetName="templateRoot" Value="3,3,0,3"/>
                        </DataTrigger>
 
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=TabStripPlacement}" Value="Right">
                            <Setter Property="BorderThickness" TargetName="templateRoot" Value="3,0,0,0"/>
                            <Setter Property="Padding" TargetName="templateRoot" Value="0,3,3,3"/>
                        </DataTrigger>
 
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=TabStripPlacement}" Value="Right">
                            <Setter Property="BorderThickness" TargetName="templateRoot" Value="0,3,0,0"/>
                            <Setter Property="Padding" TargetName="templateRoot" Value="3,0,3,3"/>
                        </DataTrigger>
 
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Foreground" TargetName="txt" Value="{StaticResource SecondaryImportant}"/>
                        </MultiDataTrigger>
 
 
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource Important}"/>
                            <Setter Property="Foreground" TargetName="txt" Value="{StaticResource Important}"/>
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
 
    <Style x:Key="ControlStyle" TargetType="{x:Type TabControl}">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="ItemContainerStyle" Value="{StaticResource tabItemStyle}"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid x:Name="templateRoot" ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0" />
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                            <RowDefinition x:Name="RowDefinition1" Height="*"/>
                        </Grid.RowDefinitions>
                        
                        <ScrollViewer Grid.Row="0" Grid.Column="0"
                                  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
                            <StackPanel x:Name="HeaderPanel" Orientation="Horizontal"
                            ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                            IsItemsHost="True"
                            Background="White"
                            Margin="0" KeyboardNavigation.TabIndex="1"
                            Panel.ZIndex="1"/>
 
                        </ScrollViewer>
 
                        <!--<Line X1="0" X2="{Binding ActualWidth, RelativeSource={RelativeSource Self}}" 
          Stroke="Transparent" StrokeThickness="0.1" 
          VerticalAlignment="Bottom" Margin="0" SnapsToDevicePixels="True"/>-->
                        <Border x:Name="ContentPanel" BorderBrush="{TemplateBinding BorderBrush}" 
            BorderThickness="{TemplateBinding BorderThickness}" 
            Background="{TemplateBinding Background}" 
            Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" 
                                Grid.Row="1" KeyboardNavigation.TabIndex="2" 
                                KeyboardNavigation.TabNavigation="Local">
                            <ContentPresenter x:Name="PART_SelectedContentHost" 
                          ContentTemplate="{TemplateBinding SelectedContentTemplate}" 
                          Content="{TemplateBinding SelectedContent}" 
                          ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" 
                          ContentSource="SelectedContent" Margin="0" 
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                            <Setter Property="Orientation" TargetName="HeaderPanel" Value="Horizontal"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
 
                            <Setter Property="Orientation" TargetName="HeaderPanel" Value="Vertical"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            
                            <Setter Property="Orientation" TargetName="HeaderPanel" Value="Vertical"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>