TabItemStyle.xaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <Style x:Key="FocusVisual">
  4. <Setter Property="Control.Template">
  5. <Setter.Value>
  6. <ControlTemplate>
  7. <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
  8. </ControlTemplate>
  9. </Setter.Value>
  10. </Setter>
  11. </Style>
  12. <LinearGradientBrush x:Key="TabItem.Static.Background" EndPoint="0,1" StartPoint="0,0">
  13. <GradientStop Color="#F0F0F0" Offset="0.0"/>
  14. <GradientStop Color="#E5E5E5" Offset="1.0"/>
  15. </LinearGradientBrush>
  16. <SolidColorBrush x:Key="TabItem.Static.Border" Color="#ACACAC"/>
  17. <LinearGradientBrush x:Key="TabItem.MouseOver.Background" EndPoint="0,1" StartPoint="0,0">
  18. <GradientStop Color="#ECF4FC" Offset="0.0"/>
  19. <GradientStop Color="#DCECFC" Offset="1.0"/>
  20. </LinearGradientBrush>
  21. <SolidColorBrush x:Key="TabItem.MouseOver.Border" Color="#7EB4EA"/>
  22. <SolidColorBrush x:Key="TabItem.Selected.Background1" Color="#1460F3"/>
  23. <SolidColorBrush x:Key="TabItem.Selected.Border1" Color="#ACACAC"/>
  24. <SolidColorBrush x:Key="TabItem.Disabled.Background" Color="#1460F3"/>
  25. <SolidColorBrush x:Key="TabItem.Disabled.Border" Color="#D9D9D9"/>
  26. <Style x:Key="TabItemStyle1" TargetType="{x:Type TabItem}">
  27. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
  28. <Setter Property="Foreground" Value="Black"/>
  29. <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
  30. <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
  31. <Setter Property="Margin" Value="0"/>
  32. <Setter Property="Padding" Value="6,2,6,2"/>
  33. <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
  34. <Setter Property="VerticalContentAlignment" Value="Stretch"/>
  35. <Setter Property="Template">
  36. <Setter.Value>
  37. <ControlTemplate TargetType="{x:Type TabItem}">
  38. <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
  39. <Border x:Name="mainBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Margin="0">
  40. <Border x:Name="innerBorder" Background="{StaticResource TabItem.Selected.Background1}" BorderBrush="{StaticResource TabItem.Selected.Border1}" BorderThickness="1,1,1,0" Margin="-1" Opacity="0"/>
  41. </Border>
  42. <ContentPresenter x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  43. </Grid>
  44. <ControlTemplate.Triggers>
  45. <MultiDataTrigger>
  46. <MultiDataTrigger.Conditions>
  47. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
  48. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
  49. </MultiDataTrigger.Conditions>
  50. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
  51. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
  52. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
  53. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
  54. </MultiDataTrigger>
  55. <MultiDataTrigger>
  56. <MultiDataTrigger.Conditions>
  57. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
  58. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
  59. </MultiDataTrigger.Conditions>
  60. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
  61. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
  62. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
  63. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
  64. </MultiDataTrigger>
  65. <MultiDataTrigger>
  66. <MultiDataTrigger.Conditions>
  67. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
  68. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
  69. </MultiDataTrigger.Conditions>
  70. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
  71. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
  72. <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
  73. <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
  74. </MultiDataTrigger>
  75. <MultiDataTrigger>
  76. <MultiDataTrigger.Conditions>
  77. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
  78. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
  79. </MultiDataTrigger.Conditions>
  80. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
  81. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
  82. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
  83. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
  84. </MultiDataTrigger>
  85. <MultiDataTrigger>
  86. <MultiDataTrigger.Conditions>
  87. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
  88. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
  89. </MultiDataTrigger.Conditions>
  90. <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
  91. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
  92. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
  93. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
  94. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
  95. </MultiDataTrigger>
  96. <MultiDataTrigger>
  97. <MultiDataTrigger.Conditions>
  98. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
  99. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
  100. </MultiDataTrigger.Conditions>
  101. <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
  102. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
  103. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
  104. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
  105. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
  106. </MultiDataTrigger>
  107. <MultiDataTrigger>
  108. <MultiDataTrigger.Conditions>
  109. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
  110. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
  111. </MultiDataTrigger.Conditions>
  112. <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
  113. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
  114. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
  115. <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
  116. <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
  117. </MultiDataTrigger>
  118. <MultiDataTrigger>
  119. <MultiDataTrigger.Conditions>
  120. <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
  121. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
  122. </MultiDataTrigger.Conditions>
  123. <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
  124. <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
  125. <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
  126. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
  127. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
  128. </MultiDataTrigger>
  129. <MultiDataTrigger>
  130. <MultiDataTrigger.Conditions>
  131. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
  132. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
  133. </MultiDataTrigger.Conditions>
  134. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
  135. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
  136. </MultiDataTrigger>
  137. <MultiDataTrigger>
  138. <MultiDataTrigger.Conditions>
  139. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
  140. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
  141. </MultiDataTrigger.Conditions>
  142. <Setter Property="Panel.ZIndex" Value="1"/>
  143. <Setter Property="Margin" Value="-2,-2,0,-2"/>
  144. <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
  145. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
  146. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
  147. </MultiDataTrigger>
  148. <MultiDataTrigger>
  149. <MultiDataTrigger.Conditions>
  150. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
  151. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
  152. </MultiDataTrigger.Conditions>
  153. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
  154. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
  155. </MultiDataTrigger>
  156. <MultiDataTrigger>
  157. <MultiDataTrigger.Conditions>
  158. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
  159. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
  160. </MultiDataTrigger.Conditions>
  161. <Setter Property="Panel.ZIndex" Value="1"/>
  162. <Setter Property="Margin" Value="-2,0,-2,-2"/>
  163. <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
  164. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
  165. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
  166. </MultiDataTrigger>
  167. <MultiDataTrigger>
  168. <MultiDataTrigger.Conditions>
  169. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
  170. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
  171. </MultiDataTrigger.Conditions>
  172. <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
  173. <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
  174. </MultiDataTrigger>
  175. <MultiDataTrigger>
  176. <MultiDataTrigger.Conditions>
  177. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
  178. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
  179. </MultiDataTrigger.Conditions>
  180. <Setter Property="Panel.ZIndex" Value="1"/>
  181. <Setter Property="Margin" Value="0,-2,-2,-2"/>
  182. <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
  183. <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
  184. <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
  185. </MultiDataTrigger>
  186. <MultiDataTrigger>
  187. <MultiDataTrigger.Conditions>
  188. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
  189. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
  190. </MultiDataTrigger.Conditions>
  191. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
  192. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
  193. </MultiDataTrigger>
  194. <MultiDataTrigger>
  195. <MultiDataTrigger.Conditions>
  196. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
  197. <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
  198. </MultiDataTrigger.Conditions>
  199. <Setter Property="Panel.ZIndex" Value="1"/>
  200. <Setter Property="Margin" Value="-2,-2,-2,0"/>
  201. <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
  202. <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
  203. <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
  204. </MultiDataTrigger>
  205. </ControlTemplate.Triggers>
  206. </ControlTemplate>
  207. </Setter.Value>
  208. </Setter>
  209. </Style>
  210. </ResourceDictionary>