Expander.axaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:content="clr-namespace:SukiUI.Content"
  4. xmlns:controls="clr-namespace:SukiUI.Controls">
  5. <Design.PreviewWith>
  6. <Border Padding="20">
  7. <Expander Header="Expander" IsExpanded="True">
  8. <TextBlock Text="Content" />
  9. </Expander>
  10. </Border>
  11. </Design.PreviewWith>
  12. <ControlTheme x:Key="SukiExpanderStyle" TargetType="Expander">
  13. <Setter Property="TextBlock.TextAlignment" Value="Start" />
  14. <Setter Property="ClipToBounds" Value="False" />
  15. <Setter Property="CornerRadius" Value="4" />
  16. <Setter Property="ContentTransition" Value="{x:Null}" />
  17. <Setter Property="Template">
  18. <ControlTemplate>
  19. <Border Name="PART_RootBorder"
  20. Background="{TemplateBinding Background}"
  21. BorderBrush="{TemplateBinding BorderBrush}"
  22. BorderThickness="{TemplateBinding BorderThickness}"
  23. CornerRadius="{TemplateBinding CornerRadius}">
  24. <Border Name="PART_InnerBorder" CornerRadius="{TemplateBinding CornerRadius}">
  25. <Panel>
  26. <controls:ContentExpandControl Name="PART_ContentExpand"
  27. HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
  28. VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
  29. Content="{TemplateBinding Content}"
  30. ContentTemplate="{TemplateBinding ContentTemplate}" />
  31. <LayoutTransformControl Name="PART_ToggleTransform">
  32. <DockPanel>
  33. <Border Name="PART_BottomBorder"
  34. Height="2"
  35. HorizontalAlignment="Stretch"
  36. Background="{DynamicResource SukiBorderBrush}"
  37. CornerRadius="10"
  38. DockPanel.Dock="Bottom"
  39. Opacity="0.8" />
  40. <ToggleButton Name="PART_ToggleButton"
  41. HorizontalAlignment="Stretch"
  42. VerticalAlignment="Center"
  43. HorizontalContentAlignment="Stretch"
  44. Background="Transparent"
  45. BorderBrush="{DynamicResource SukiBorderBrush}"
  46. BorderThickness="0"
  47. Classes="Basic"
  48. DockPanel.Dock="Right"
  49. IsChecked="{TemplateBinding IsExpanded,
  50. Mode=TwoWay}">
  51. <Grid ColumnDefinitions="Auto,*,Auto">
  52. <ContentPresenter Grid.Column="0"
  53. HorizontalAlignment="Left"
  54. VerticalAlignment="Center"
  55. Content="{TemplateBinding Header}"
  56. FontWeight="{DynamicResource DefaultDemiBold}" />
  57. <PathIcon Name="PART_Icon"
  58. Grid.Column="2"
  59. Width="10"
  60. Height="10"
  61. Margin="10,0,0,0"
  62. Data="{x:Static content:Icons.Plus}" />
  63. </Grid>
  64. </ToggleButton>
  65. </DockPanel>
  66. </LayoutTransformControl>
  67. </Panel>
  68. </Border>
  69. </Border>
  70. </ControlTemplate>
  71. </Setter>
  72. <Style Selector="^:not(.no-transitions) /template/ controls|ContentExpandControl#PART_ContentExpand">
  73. <Setter Property="Transitions">
  74. <Transitions>
  75. <DoubleTransition Easing="CircularEaseOut"
  76. Property="Multiplier"
  77. Duration="0.25" />
  78. </Transitions>
  79. </Setter>
  80. </Style>
  81. <Style Selector="^ /template/ Border#PART_InnerBorder">
  82. <Setter Property="ClipToBounds" Value="True" />
  83. </Style>
  84. <Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
  85. <Setter Property="ClipToBounds" Value="False" />
  86. </Style>
  87. <Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
  88. <Setter Property="Multiplier" Value="0" />
  89. </Style>
  90. <Style Selector="^:expanded /template/ controls|ContentExpandControl#PART_ContentExpand">
  91. <Setter Property="Multiplier" Value="1" />
  92. </Style>
  93. <Style Selector="^:expanded /template/ PathIcon#PART_Icon">
  94. <Setter Property="Data" Value="{x:Static content:Icons.Minus}" />
  95. </Style>
  96. <Style Selector="^:up">
  97. <Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
  98. <Setter Property="Orientation" Value="Vertical" />
  99. <Setter Property="VerticalAlignment" Value="Bottom" />
  100. <Setter Property="Margin" Value="0,0,0,48" />
  101. </Style>
  102. <Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
  103. <Setter Property="VerticalAlignment" Value="Bottom" />
  104. </Style>
  105. <Style Selector="^ /template/ Border#PART_BottomBorder">
  106. <Setter Property="DockPanel.Dock" Value="Top" />
  107. </Style>
  108. </Style>
  109. <Style Selector="^:down">
  110. <Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
  111. <Setter Property="Orientation" Value="Vertical" />
  112. <Setter Property="VerticalAlignment" Value="Top" />
  113. <Setter Property="Margin" Value="0,48,0,0" />
  114. </Style>
  115. <Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
  116. <Setter Property="VerticalAlignment" Value="Top" />
  117. </Style>
  118. </Style>
  119. <Style Selector="^:left">
  120. <Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
  121. <Setter Property="Orientation" Value="Horizontal" />
  122. <Setter Property="HorizontalAlignment" Value="Right" />
  123. <Setter Property="Margin" Value="0,0,48,0" />
  124. </Style>
  125. <Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
  126. <Setter Property="LayoutTransform" Value="rotate(90deg)" />
  127. <Setter Property="HorizontalAlignment" Value="Right" />
  128. </Style>
  129. </Style>
  130. <Style Selector="^:right">
  131. <Style Selector="^ /template/ controls|ContentExpandControl#PART_ContentExpand">
  132. <Setter Property="Orientation" Value="Horizontal" />
  133. <Setter Property="HorizontalAlignment" Value="Left" />
  134. <Setter Property="Margin" Value="48,0,0,0" />
  135. </Style>
  136. <Style Selector="^ /template/ LayoutTransformControl#PART_ToggleTransform">
  137. <Setter Property="LayoutTransform" Value="rotate(90deg)" />
  138. <Setter Property="HorizontalAlignment" Value="Left" />
  139. </Style>
  140. <Style Selector="^ /template/ Border#PART_BottomBorder">
  141. <Setter Property="DockPanel.Dock" Value="Top" />
  142. </Style>
  143. </Style>
  144. </ControlTheme>
  145. <ControlTheme x:Key="{x:Type Expander}"
  146. BasedOn="{StaticResource SukiExpanderStyle}"
  147. TargetType="Expander" />
  148. </ResourceDictionary>