TabControlStyles.xaml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <Styles 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">
  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. <Styles.Resources>
  22. <Thickness x:Key="TabControlTopPlacementItemMargin">0 0 0 2</Thickness>
  23. </Styles.Resources>
  24. <Style Selector="TabControl">
  25. <Setter Property="Margin" Value="0" />
  26. <Setter Property="Padding" Value="{DynamicResource TabItemMargin}" />
  27. <Setter Property="Background" Value="{DynamicResource TabControlBackground}" />
  28. <Setter Property="Template">
  29. <ControlTemplate>
  30. <Border HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
  31. VerticalAlignment="{TemplateBinding VerticalAlignment}"
  32. Background="{TemplateBinding Background}"
  33. BorderBrush="{TemplateBinding BorderBrush}"
  34. BorderThickness="{TemplateBinding BorderThickness}"
  35. CornerRadius="{TemplateBinding CornerRadius}">
  36. <DockPanel>
  37. <LayoutTransformControl Name="PART_LayoutTransform" DockPanel.Dock="{TemplateBinding TabStripPlacement}">
  38. <ItemsPresenter Name="PART_ItemsPresenter" ItemsPanel="{TemplateBinding ItemsPanel}" />
  39. </LayoutTransformControl>
  40. <ContentPresenter Name="PART_SelectedContentHost"
  41. Margin="{TemplateBinding Padding}"
  42. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  43. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  44. Content="{TemplateBinding SelectedContent}"
  45. ContentTemplate="{TemplateBinding SelectedContentTemplate}" />
  46. </DockPanel>
  47. </Border>
  48. </ControlTemplate>
  49. </Setter>
  50. </Style>
  51. <Style Selector="TabControl[TabStripPlacement=Left] /template/ LayoutTransformControl#PART_LayoutTransform">
  52. <Setter Property="LayoutTransform" Value="rotate(-90deg)" />
  53. <Style Selector="^ ItemsPresenter#PART_ItemsPresenter &gt; WrapPanel">
  54. <Setter Property="Orientation" Value="Horizontal" />
  55. </Style>
  56. </Style>
  57. <Style Selector="TabControl[TabStripPlacement=Right] /template/ LayoutTransformControl#PART_LayoutTransform">
  58. <Setter Property="LayoutTransform" Value="rotate(90deg)" />
  59. <Style Selector="^ ItemsPresenter#PART_ItemsPresenter &gt; WrapPanel">
  60. <Setter Property="Orientation" Value="Horizontal" />
  61. </Style>
  62. </Style>
  63. <Style Selector="TabControl[TabStripPlacement=Top] /template/ ItemsPresenter#PART_ItemsPresenter">
  64. <Setter Property="Margin" Value="{DynamicResource TabControlTopPlacementItemMargin}" />
  65. </Style>
  66. </Styles>