TabControlStyle.xaml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. <Style x:Key="LineTabControlStyle" TargetType="{x:Type TabControl}">
  69. <Setter Property="Background" Value="#ffffff"></Setter>
  70. <Setter Property="BorderThickness" Value="0"></Setter>
  71. <Setter Property="BorderBrush" Value="Transparent"></Setter>
  72. <Setter Property="Padding" Value="5"></Setter>
  73. <Setter Property="VerticalAlignment" Value="Center"></Setter>
  74. <Setter Property="HorizontalAlignment" Value="Center"></Setter>
  75. <Setter Property="Template">
  76. <Setter.Value>
  77. <ControlTemplate TargetType="{x:Type TabControl}">
  78. <Grid>
  79. <Grid.RowDefinitions>
  80. <RowDefinition Height="50"></RowDefinition>
  81. <RowDefinition Height="*"></RowDefinition>
  82. </Grid.RowDefinitions>
  83. <TabPanel Grid.Row="0"
  84. Panel.ZIndex="1"
  85. Background="Transparent"
  86. IsItemsHost="True"
  87. HorizontalAlignment="Center"></TabPanel>
  88. <Border Grid.Row="1"
  89. CornerRadius="5"
  90. BorderThickness="{TemplateBinding BorderThickness}"
  91. BorderBrush="{TemplateBinding BorderBrush}"
  92. Background="{TemplateBinding Background}">
  93. <ContentPresenter ContentSource="SelectedContent"
  94. SnapsToDevicePixels="True"
  95. Margin="{TemplateBinding Padding}"></ContentPresenter>
  96. </Border>
  97. </Grid>
  98. </ControlTemplate>
  99. </Setter.Value>
  100. </Setter>
  101. </Style>
  102. </ResourceDictionary>