ScrollBarStyle.axaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <Styles xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:content="clr-namespace:SukiUI.Content"
  4. xmlns:converters="clr-namespace:SukiUI.Converters"
  5. xmlns:theme="clr-namespace:SukiUI.Theme">
  6. <Design.PreviewWith>
  7. <StackPanel Width="200">
  8. <Border Padding="20">
  9. <ScrollViewer Width="200"
  10. Height="100"
  11. >
  12. <StackPanel>
  13. <ListBoxItem>isse</ListBoxItem>
  14. <ListBoxItem>isse</ListBoxItem>
  15. <ListBoxItem>isse</ListBoxItem>
  16. <ListBoxItem>isse</ListBoxItem>
  17. <ListBoxItem>isse</ListBoxItem>
  18. <ListBoxItem>isse</ListBoxItem>
  19. <ListBoxItem>isse</ListBoxItem>
  20. <ListBoxItem>isse</ListBoxItem>
  21. <ListBoxItem>isse</ListBoxItem>
  22. <ListBoxItem>isse</ListBoxItem>
  23. <ListBoxItem>isse</ListBoxItem>
  24. <ListBoxItem>isse</ListBoxItem>
  25. <ListBoxItem>isse</ListBoxItem>
  26. <ListBoxItem>isse</ListBoxItem>
  27. <ListBoxItem>isse</ListBoxItem>
  28. <ListBoxItem>isse</ListBoxItem>
  29. <ListBoxItem>isse</ListBoxItem>
  30. <ListBoxItem>isse</ListBoxItem>
  31. <ListBoxItem>isse</ListBoxItem>
  32. <ListBoxItem>isse</ListBoxItem>
  33. <ListBoxItem>isse</ListBoxItem>
  34. <ListBoxItem>isse</ListBoxItem>
  35. <ListBoxItem>isse</ListBoxItem>
  36. <ListBoxItem>isse</ListBoxItem>
  37. <ListBoxItem>isse</ListBoxItem>
  38. <ListBoxItem>isse</ListBoxItem>
  39. <ListBoxItem>isse</ListBoxItem>
  40. <ListBoxItem>isse</ListBoxItem>
  41. <ListBoxItem>isse</ListBoxItem>
  42. <ListBoxItem>isse</ListBoxItem>
  43. </StackPanel>
  44. </ScrollViewer>
  45. </Border>
  46. <ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Auto">
  47. <StackPanel Width="500" Orientation="Horizontal">
  48. <Panel Width="50"
  49. Height="50"
  50. Margin="5"
  51. Background="Gray" />
  52. <Panel Width="50"
  53. Height="50"
  54. Margin="5"
  55. Background="Gray" />
  56. <Panel Width="50"
  57. Height="50"
  58. Margin="5"
  59. Background="Gray" />
  60. <Panel Width="50"
  61. Height="50"
  62. Margin="5"
  63. Background="Gray" />
  64. <Panel Width="50"
  65. Height="50"
  66. Margin="5"
  67. Background="Gray" />
  68. </StackPanel>
  69. </ScrollViewer>
  70. </StackPanel>
  71. </Design.PreviewWith>
  72. <Style Selector="ScrollBar:vertical">
  73. <Setter Property="AllowAutoHide" Value="False"></Setter>
  74. <Setter Property="Template">
  75. <ControlTemplate>
  76. <Border Background="Transparent" UseLayoutRounding="False">
  77. <Grid RowDefinitions="Auto,*,Auto">
  78. <Track Grid.Row="1"
  79. Grid.Column="1"
  80. IsDirectionReversed="True"
  81. Maximum="{TemplateBinding Maximum}"
  82. Minimum="{TemplateBinding Minimum}"
  83. Orientation="{TemplateBinding Orientation}"
  84. ViewportSize="{TemplateBinding ViewportSize}"
  85. Value="{TemplateBinding Value,
  86. Mode=TwoWay}">
  87. <Track.DecreaseButton>
  88. <RepeatButton Name="PART_PageUpButton"
  89. Background="Transparent"
  90. Classes="repeattrack"
  91. Focusable="False" />
  92. </Track.DecreaseButton>
  93. <Track.IncreaseButton>
  94. <RepeatButton Name="PART_PageDownButton"
  95. Background="Transparent"
  96. Classes="repeattrack"
  97. Focusable="False" />
  98. </Track.IncreaseButton>
  99. <Thumb Name="thumb">
  100. <Thumb.Template>
  101. <ControlTemplate>
  102. <Panel>
  103. <Border Name="ThumbBarVertical" Margin="0,3" Width="3"
  104. Background="{DynamicResource SukiMediumBorderBrush}"
  105. CornerRadius="{DynamicResource MediumCornerRadius}" >
  106. <Border.Transitions>
  107. <Transitions>
  108. <BrushTransition Property="Background" Duration="0:0:0.15"></BrushTransition>
  109. <DoubleTransition Property="Width" Duration="0:0:0.1"></DoubleTransition>
  110. </Transitions>
  111. </Border.Transitions>
  112. </Border>
  113. </Panel>
  114. </ControlTemplate>
  115. </Thumb.Template>
  116. </Thumb>
  117. </Track>
  118. </Grid>
  119. </Border>
  120. </ControlTemplate>
  121. </Setter>
  122. </Style>
  123. <Style Selector="ScrollBar.Stack:vertical">
  124. <Setter Property="HorizontalAlignment" Value="Stretch" />
  125. <Setter Property="Width" Value="NaN" />
  126. <Setter Property="Template">
  127. <ControlTemplate>
  128. <Grid HorizontalAlignment="Stretch" RowDefinitions="Auto,*,Auto">
  129. <RepeatButton Name="PART_PageUpButton"
  130. Height="60"
  131. HorizontalAlignment="Stretch"
  132. Background="Transparent"
  133. BorderThickness="0"
  134. Focusable="False">
  135. <RepeatButton.IsVisible>
  136. <MultiBinding Converter="{x:Static converters:SideMenuScrollerToVisibilityBool.Up}">
  137. <Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}" />
  138. <Binding Path="Minimum" RelativeSource="{RelativeSource TemplatedParent}" />
  139. </MultiBinding>
  140. </RepeatButton.IsVisible>
  141. <PathIcon Width="10"
  142. Height="25"
  143. Data="{x:Static content:Icons.ChevronUp}"
  144. Foreground="{DynamicResource SukiText}">
  145. <PathIcon.RenderTransform>
  146. <ScaleTransform ScaleX="1" />
  147. </PathIcon.RenderTransform>
  148. </PathIcon>
  149. </RepeatButton>
  150. <RepeatButton Name="PART_PageDownButton"
  151. Grid.Row="2"
  152. Height="60"
  153. HorizontalAlignment="Stretch"
  154. Background="Transparent"
  155. BorderThickness="0"
  156. Focusable="False">
  157. <RepeatButton.IsVisible>
  158. <MultiBinding Converter="{x:Static converters:SideMenuScrollerToVisibilityBool.Down}">
  159. <Binding Path="Value" RelativeSource="{RelativeSource TemplatedParent}" />
  160. <Binding Path="Maximum" RelativeSource="{RelativeSource TemplatedParent}" />
  161. </MultiBinding>
  162. </RepeatButton.IsVisible>
  163. <PathIcon Width="10"
  164. Height="25"
  165. Data="{x:Static content:Icons.ChevronDown}"
  166. Foreground="{DynamicResource SukiText}">
  167. <PathIcon.RenderTransform>
  168. <ScaleTransform ScaleX="1" />
  169. </PathIcon.RenderTransform>
  170. </PathIcon>
  171. </RepeatButton>
  172. </Grid>
  173. </ControlTemplate>
  174. </Setter>
  175. </Style>
  176. <Style Selector="ScrollBar:horizontal">
  177. <Setter Property="AllowAutoHide" Value="False"></Setter>
  178. <Setter Property="Template">
  179. <ControlTemplate>
  180. <Border Background="Transparent" UseLayoutRounding="False">
  181. <Grid >
  182. <Track
  183. IsDirectionReversed="False"
  184. Maximum="{TemplateBinding Maximum}"
  185. Minimum="{TemplateBinding Minimum}"
  186. Orientation="{TemplateBinding Orientation}"
  187. ViewportSize="{TemplateBinding ViewportSize}"
  188. Value="{TemplateBinding Value,
  189. Mode=TwoWay}">
  190. <Track.DecreaseButton>
  191. <RepeatButton Name="PART_PageUpButton"
  192. Background="Transparent"
  193. Classes="repeattrack"
  194. Focusable="False" />
  195. </Track.DecreaseButton>
  196. <Track.IncreaseButton>
  197. <RepeatButton Name="PART_PageDownButton"
  198. Background="Transparent"
  199. Classes="repeattrack"
  200. Focusable="False" />
  201. </Track.IncreaseButton>
  202. <Thumb Name="thumb">
  203. <Thumb.Template>
  204. <ControlTemplate>
  205. <Panel>
  206. <Border Height="3" Name="ThumbBarHorizontal"
  207. Margin="3,0"
  208. Background="{DynamicResource SukiMediumBorderBrush}"
  209. CornerRadius="10" >
  210. <Border.Transitions>
  211. <Transitions>
  212. <BrushTransition Property="Background" Duration="0:0:0.15"></BrushTransition>
  213. <DoubleTransition Property="Height" Duration="0:0:0.1"></DoubleTransition>
  214. </Transitions>
  215. </Border.Transitions>
  216. </Border>
  217. </Panel>
  218. </ControlTemplate>
  219. </Thumb.Template>
  220. </Thumb>
  221. </Track>
  222. </Grid>
  223. </Border>
  224. </ControlTemplate>
  225. </Setter>
  226. </Style>
  227. <Style Selector="ScrollViewer:pointerover /template/ ScrollBar">
  228. <Setter Property="AllowAutoHide" Value="True"></Setter>
  229. </Style>
  230. <Style Selector="ScrollBar[AllowAutoHide=True] Border#ThumbBarVertical">
  231. <Setter Property="Background" Value="{DynamicResource SukiControlBorderBrush}"></Setter>
  232. <Setter Property="Width" Value="8"></Setter>
  233. </Style>
  234. <Style Selector="ScrollBar[AllowAutoHide=True] Border#ThumbBarHorizontal">
  235. <Setter Property="Background" Value="{DynamicResource SukiControlBorderBrush}"></Setter>
  236. <Setter Property="Height" Value="8"></Setter>
  237. </Style>
  238. </Styles>