TabControlStyle.xaml 5.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <SolidColorBrush x:Key="TabItem.Selected.Background" Color="#FFFFFF"/>
  4. <SolidColorBrush x:Key="TabItem.Selected.Border" Color="#ACACAC"/>
  5. <Style x:Key="TabControlStyle1" TargetType="{x:Type TabControl}">
  6. <Setter Property="Padding" Value="2"/>
  7. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  8. <Setter Property="VerticalContentAlignment" Value="Center"/>
  9. <Setter Property="Background" Value="{StaticResource TabItem.Selected.Background}"/>
  10. <Setter Property="BorderBrush" Value="{StaticResource TabItem.Selected.Border}"/>
  11. <Setter Property="BorderThickness" Value="1"/>
  12. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  13. <Setter Property="Template">
  14. <Setter.Value>
  15. <ControlTemplate TargetType="{x:Type TabControl}">
  16. <Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
  17. <Grid.ColumnDefinitions>
  18. <ColumnDefinition x:Name="ColumnDefinition0"/>
  19. <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
  20. </Grid.ColumnDefinitions>
  21. <Grid.RowDefinitions>
  22. <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
  23. <RowDefinition x:Name="RowDefinition1" Height="*"/>
  24. </Grid.RowDefinitions>
  25. <UniformGrid x:Name="headerPanel" Background="Transparent" Grid.Column="0" HorizontalAlignment="Stretch" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1" Rows="1"/>
  26. <Border x:Name="contentPanel" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
  27. <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  28. </Border>
  29. </Grid>
  30. <ControlTemplate.Triggers>
  31. <Trigger Property="TabStripPlacement" Value="Bottom">
  32. <Setter Property="Grid.Row" TargetName="headerPanel" Value="1"/>
  33. <Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
  34. <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
  35. <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
  36. <Setter Property="Margin" TargetName="headerPanel" Value="2,0,2,2"/>
  37. </Trigger>
  38. <Trigger Property="TabStripPlacement" Value="Left">
  39. <Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
  40. <Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
  41. <Setter Property="Grid.Column" TargetName="headerPanel" Value="0"/>
  42. <Setter Property="Grid.Column" TargetName="contentPanel" Value="1"/>
  43. <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
  44. <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
  45. <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
  46. <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
  47. <Setter Property="Margin" TargetName="headerPanel" Value="2,2,0,2"/>
  48. </Trigger>
  49. <Trigger Property="TabStripPlacement" Value="Right">
  50. <Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
  51. <Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
  52. <Setter Property="Grid.Column" TargetName="headerPanel" Value="1"/>
  53. <Setter Property="Grid.Column" TargetName="contentPanel" Value="0"/>
  54. <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
  55. <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
  56. <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
  57. <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
  58. <Setter Property="Margin" TargetName="headerPanel" Value="0,2,2,2"/>
  59. </Trigger>
  60. <Trigger Property="IsEnabled" Value="false">
  61. <Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  62. </Trigger>
  63. </ControlTemplate.Triggers>
  64. </ControlTemplate>
  65. </Setter.Value>
  66. </Setter>
  67. </Style>
  68. </ResourceDictionary>