TabItem.axaml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <Design.PreviewWith>
  3. <Border Width="400" Height="400">
  4. <Panel>
  5. <TabControl Margin="0,0,0,200" TabStripPlacement="Bottom">
  6. <TabItem Header="Arch">
  7. <Border Height="100" Background="AntiqueWhite">
  8. <TextBlock FontSize="20"
  9. Foreground="Black"
  10. Text="Content" />
  11. </Border>
  12. </TabItem>
  13. <TabItem Header="Leaf">
  14. <Border Height="100" Background="Green" />
  15. </TabItem>
  16. <TabItem Header="Disabled" IsEnabled="False" />
  17. </TabControl>
  18. </Panel>
  19. </Border>
  20. </Design.PreviewWith>
  21. <ControlTheme x:Key="SukiTabItemStyle" TargetType="TabItem">
  22. <Setter Property="FontSize" Value="50" />
  23. <Setter Property="FontWeight" Value="Bold" />
  24. <Setter Property="Background" Value="Transparent" />
  25. <Setter Property="Margin" Value="0" />
  26. <Setter Property="MinHeight" Value="{DynamicResource TabItemMinHeight}" />
  27. <Setter Property="VerticalContentAlignment" Value="Bottom" />
  28. <Setter Property="Template">
  29. <ControlTemplate>
  30. <Border Name="PART_LayoutRoot"
  31. Margin="8,0"
  32. Padding="{TemplateBinding Padding}"
  33. Background="Transparent"
  34. BorderBrush="{TemplateBinding BorderBrush}"
  35. BorderThickness="{TemplateBinding BorderThickness}"
  36. CornerRadius="{TemplateBinding CornerRadius}">
  37. <StackPanel>
  38. <ContentPresenter Name="PART_HeaderPresenter"
  39. Padding="0,5"
  40. HorizontalAlignment="Center"
  41. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  42. HorizontalContentAlignment="Center"
  43. Content="{TemplateBinding Header}"
  44. ContentTemplate="{TemplateBinding HeaderTemplate}"
  45. TextBlock.FontFamily="{TemplateBinding FontFamily}"
  46. TextBlock.FontSize="{TemplateBinding FontSize}"
  47. TextBlock.FontWeight="{TemplateBinding FontWeight}">
  48. <ContentPresenter.Transitions>
  49. <Transitions>
  50. <BrushTransition Property="Foreground" Duration="0:0:0.1" />
  51. </Transitions>
  52. </ContentPresenter.Transitions>
  53. </ContentPresenter>
  54. <Border Name="PART_Underline"
  55. Height="3"
  56. Margin="10,0,10,0"
  57. Background="{DynamicResource SukiPrimaryColor}"
  58. CornerRadius="55"
  59. Opacity="0">
  60. <Border.Transitions>
  61. <Transitions>
  62. <DoubleTransition Property="Opacity" Duration="0:0:0.3" />
  63. </Transitions>
  64. </Border.Transitions>
  65. </Border>
  66. </StackPanel>
  67. </Border>
  68. </ControlTemplate>
  69. </Setter>
  70. <Style Selector="^:selected /template/ Border#PART_Underline">
  71. <Setter Property="Opacity" Value="1" />
  72. </Style>
  73. <Style Selector="^ /template/ Border#PART_LayoutRoot">
  74. <Setter Property="Background" Value="{Binding $parent[TabItem].Background}" />
  75. </Style>
  76. <Style Selector="^:pointerover">
  77. <Setter Property="Background" Value="Transparent" />
  78. <Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter">
  79. <Setter Property="TextBlock.Foreground" Value="{DynamicResource SukiPrimaryColor75}" />
  80. </Style>
  81. </Style>
  82. <Style Selector="^:selected">
  83. <Setter Property="Background" Value="Transparent" />
  84. <Setter Property="CornerRadius" Value="{DynamicResource SmallCornerRadius}" />
  85. <Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter">
  86. <Setter Property="TextBlock.Foreground" Value="{DynamicResource SukiPrimaryColor}" />
  87. </Style>
  88. <Style Selector="^ /template/ Border#PART_SelectedPipe">
  89. <Setter Property="Opacity" Value="1" />
  90. </Style>
  91. </Style>
  92. <Style Selector="^[IsEnabled=False]">
  93. <Setter Property="Foreground" Value="{DynamicResource SukiDisabledText}" />
  94. </Style>
  95. <Style Selector="^[TabStripPlacement=Bottom]">
  96. <Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter">
  97. <Setter Property="DockPanel.Dock" Value="Bottom" />
  98. <Setter Property="Margin" Value="0,0,0,0" />
  99. </Style>
  100. <Style Selector="^ Border#PART_Underline">
  101. <Setter Property="Margin" Value="10,0,10,0" />
  102. </Style>
  103. </Style>
  104. </ControlTheme>
  105. <ControlTheme x:Key="{x:Type TabItem}"
  106. BasedOn="{StaticResource SukiTabItemStyle}"
  107. TargetType="TabItem" />
  108. </ResourceDictionary>