星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

StyleScrolllview.xaml 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <!-- ScrollViewer 滚动条 -->
  3. <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
  4. <Setter Property="OverridesDefaultStyle" Value="true" />
  5. <Setter Property="IsTabStop" Value="false" />
  6. <Setter Property="Template">
  7. <Setter.Value>
  8. <ControlTemplate TargetType="{x:Type Thumb}">
  9. <Grid>
  10. <!-- 滚动条颜色 -->
  11. <Border Background="#646465" CornerRadius="3" />
  12. </Grid>
  13. </ControlTemplate>
  14. </Setter.Value>
  15. </Setter>
  16. </Style>
  17. <Style x:Key="HorizontalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
  18. <Setter Property="OverridesDefaultStyle" Value="true" />
  19. <Setter Property="Background" Value="Transparent" />
  20. <Setter Property="Focusable" Value="false" />
  21. <Setter Property="IsTabStop" Value="false" />
  22. <Setter Property="Opacity" Value="0.2" />
  23. <Setter Property="Template">
  24. <Setter.Value>
  25. <ControlTemplate TargetType="{x:Type RepeatButton}">
  26. <Rectangle
  27. Width="{TemplateBinding Width}"
  28. Height="{TemplateBinding Height}"
  29. Fill="{TemplateBinding Background}" />
  30. </ControlTemplate>
  31. </Setter.Value>
  32. </Setter>
  33. </Style>
  34. <Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
  35. <Setter Property="OverridesDefaultStyle" Value="true" />
  36. <Setter Property="Background" Value="Transparent" />
  37. <Setter Property="Focusable" Value="false" />
  38. <Setter Property="IsTabStop" Value="false" />
  39. <Setter Property="Opacity" Value="0.2" />
  40. <Setter Property="Template">
  41. <Setter.Value>
  42. <ControlTemplate TargetType="{x:Type RepeatButton}">
  43. <Rectangle
  44. Width="{TemplateBinding Width}"
  45. Height="{TemplateBinding Height}"
  46. Fill="{TemplateBinding Background}" />
  47. </ControlTemplate>
  48. </Setter.Value>
  49. </Setter>
  50. </Style>
  51. <!-- 滚动条上下按钮 -->
  52. <Style x:Key="VerticalScrollBarPageButton2" TargetType="{x:Type RepeatButton}">
  53. <Setter Property="OverridesDefaultStyle" Value="true" />
  54. <Setter Property="Background" Value="Transparent" />
  55. <Setter Property="Focusable" Value="false" />
  56. <Setter Property="IsTabStop" Value="false" />
  57. <Setter Property="Opacity" Value="0" />
  58. <Setter Property="Template">
  59. <Setter.Value>
  60. <ControlTemplate TargetType="{x:Type RepeatButton}">
  61. <Rectangle
  62. Width="0"
  63. Height="0"
  64. Fill="#90000000" />
  65. </ControlTemplate>
  66. </Setter.Value>
  67. </Setter>
  68. </Style>
  69. <Style x:Key="for_scrollbar" TargetType="{x:Type ScrollBar}">
  70. <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
  71. <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
  72. <Setter Property="Background" Value="Transparent" />
  73. <Setter Property="Margin" Value="0,1,1,6" />
  74. <Setter Property="Width" Value="10" />
  75. <Setter Property="MinWidth" Value="5" />
  76. <Setter Property="Opacity" Value="0.2" />
  77. <Setter Property="Template">
  78. <Setter.Value>
  79. <ControlTemplate TargetType="{x:Type ScrollBar}">
  80. <Grid x:Name="Bg" SnapsToDevicePixels="true">
  81. <Grid.RowDefinitions>
  82. <RowDefinition Height="auto" />
  83. <RowDefinition Height="*" />
  84. <RowDefinition Height="auto" />
  85. </Grid.RowDefinitions>
  86. <RepeatButton
  87. Grid.Row="0"
  88. Command="{x:Static ScrollBar.PageUpCommand}"
  89. Style="{StaticResource VerticalScrollBarPageButton2}" />
  90. <Track
  91. x:Name="PART_Track"
  92. Grid.Row="1"
  93. IsDirectionReversed="true"
  94. IsEnabled="{TemplateBinding IsMouseOver}">
  95. <Track.DecreaseRepeatButton>
  96. <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource VerticalScrollBarPageButton}" />
  97. </Track.DecreaseRepeatButton>
  98. <Track.IncreaseRepeatButton>
  99. <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}" />
  100. </Track.IncreaseRepeatButton>
  101. <Track.Thumb>
  102. <Thumb Style="{StaticResource ScrollBarThumb}" />
  103. </Track.Thumb>
  104. </Track>
  105. <RepeatButton
  106. Grid.Row="2"
  107. Command="{x:Static ScrollBar.PageDownCommand}"
  108. Style="{StaticResource VerticalScrollBarPageButton2}" />
  109. </Grid>
  110. </ControlTemplate>
  111. </Setter.Value>
  112. </Setter>
  113. <Style.Triggers>
  114. <Trigger Property="Orientation" Value="Horizontal">
  115. <Setter Property="Background" Value="Transparent" />
  116. <Setter Property="Margin" Value="1,0,6,1" />
  117. <Setter Property="Height" Value="5" />
  118. <Setter Property="MinHeight" Value="5" />
  119. <Setter Property="Width" Value="Auto" />
  120. <Setter Property="Opacity" Value="0.2" />
  121. <Setter Property="Template">
  122. <Setter.Value>
  123. <ControlTemplate TargetType="{x:Type ScrollBar}">
  124. <Grid x:Name="Bg" SnapsToDevicePixels="true">
  125. <Track x:Name="PART_Track" IsEnabled="{TemplateBinding IsMouseOver}">
  126. <Track.DecreaseRepeatButton>
  127. <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}" />
  128. </Track.DecreaseRepeatButton>
  129. <Track.IncreaseRepeatButton>
  130. <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}" />
  131. </Track.IncreaseRepeatButton>
  132. <Track.Thumb>
  133. <Thumb Style="{StaticResource ScrollBarThumb}" />
  134. </Track.Thumb>
  135. </Track>
  136. </Grid>
  137. </ControlTemplate>
  138. </Setter.Value>
  139. </Setter>
  140. </Trigger>
  141. </Style.Triggers>
  142. </Style>
  143. <Style x:Key="for_scrollviewer" TargetType="{x:Type ScrollViewer}">
  144. <Setter Property="BorderBrush" Value="LightGray" />
  145. <Setter Property="BorderThickness" Value="0" />
  146. <Setter Property="Template">
  147. <Setter.Value>
  148. <ControlTemplate TargetType="{x:Type ScrollViewer}">
  149. <Border
  150. BorderBrush="{TemplateBinding BorderBrush}"
  151. BorderThickness="{TemplateBinding BorderThickness}"
  152. SnapsToDevicePixels="True">
  153. <Grid Background="{TemplateBinding Background}">
  154. <ScrollContentPresenter
  155. MinHeight="{TemplateBinding Height}"
  156. Margin="{TemplateBinding Padding}"
  157. VerticalAlignment="Center"
  158. ContentTemplate="{TemplateBinding ContentTemplate}"
  159. Cursor="{TemplateBinding Cursor}" />
  160. <ScrollBar
  161. x:Name="PART_VerticalScrollBar"
  162. HorizontalAlignment="Right"
  163. Maximum="{TemplateBinding ScrollableHeight}"
  164. Orientation="Vertical"
  165. Style="{StaticResource for_scrollbar}"
  166. ViewportSize="{TemplateBinding ViewportHeight}"
  167. Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
  168. Value="{TemplateBinding VerticalOffset}" />
  169. <ScrollBar
  170. x:Name="PART_HorizontalScrollBar"
  171. VerticalAlignment="Bottom"
  172. Maximum="{TemplateBinding ScrollableWidth}"
  173. Orientation="Horizontal"
  174. Style="{StaticResource for_scrollbar}"
  175. ViewportSize="{TemplateBinding ViewportWidth}"
  176. Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
  177. Value="{TemplateBinding HorizontalOffset}" />
  178. </Grid>
  179. </Border>
  180. <ControlTemplate.Triggers>
  181. <EventTrigger RoutedEvent="ScrollChanged">
  182. <BeginStoryboard>
  183. <Storyboard>
  184. <DoubleAnimation
  185. Storyboard.TargetName="PART_VerticalScrollBar"
  186. Storyboard.TargetProperty="Opacity"
  187. To="0.8"
  188. Duration="0:0:1" />
  189. <DoubleAnimation
  190. BeginTime="0:0:1"
  191. Storyboard.TargetName="PART_VerticalScrollBar"
  192. Storyboard.TargetProperty="Opacity"
  193. To="0.2"
  194. Duration="0:0:1" />
  195. <DoubleAnimation
  196. Storyboard.TargetName="PART_HorizontalScrollBar"
  197. Storyboard.TargetProperty="Opacity"
  198. To="0.8"
  199. Duration="0:0:1" />
  200. <DoubleAnimation
  201. BeginTime="0:0:1"
  202. Storyboard.TargetName="PART_HorizontalScrollBar"
  203. Storyboard.TargetProperty="Opacity"
  204. To="0.2"
  205. Duration="0:0:1" />
  206. </Storyboard>
  207. </BeginStoryboard>
  208. </EventTrigger>
  209. <EventTrigger RoutedEvent="MouseEnter" SourceName="PART_VerticalScrollBar">
  210. <BeginStoryboard>
  211. <Storyboard>
  212. <DoubleAnimation
  213. Storyboard.TargetName="PART_VerticalScrollBar"
  214. Storyboard.TargetProperty="Opacity"
  215. To="0.8"
  216. Duration="0:0:0.7" />
  217. </Storyboard>
  218. </BeginStoryboard>
  219. </EventTrigger>
  220. <EventTrigger RoutedEvent="MouseLeave" SourceName="PART_VerticalScrollBar">
  221. <BeginStoryboard>
  222. <Storyboard>
  223. <DoubleAnimation
  224. Storyboard.TargetName="PART_VerticalScrollBar"
  225. Storyboard.TargetProperty="Opacity"
  226. To="0.2"
  227. Duration="0:0:0.7" />
  228. </Storyboard>
  229. </BeginStoryboard>
  230. </EventTrigger>
  231. <EventTrigger RoutedEvent="MouseEnter" SourceName="PART_HorizontalScrollBar">
  232. <BeginStoryboard>
  233. <Storyboard>
  234. <DoubleAnimation
  235. Storyboard.TargetName="PART_HorizontalScrollBar"
  236. Storyboard.TargetProperty="Opacity"
  237. To="0.8"
  238. Duration="0:0:0.7" />
  239. </Storyboard>
  240. </BeginStoryboard>
  241. </EventTrigger>
  242. <EventTrigger RoutedEvent="MouseLeave" SourceName="PART_HorizontalScrollBar">
  243. <BeginStoryboard>
  244. <Storyboard>
  245. <DoubleAnimation
  246. Storyboard.TargetName="PART_HorizontalScrollBar"
  247. Storyboard.TargetProperty="Opacity"
  248. To="0.2"
  249. Duration="0:0:0.7" />
  250. </Storyboard>
  251. </BeginStoryboard>
  252. </EventTrigger>
  253. </ControlTemplate.Triggers>
  254. </ControlTemplate>
  255. </Setter.Value>
  256. </Setter>
  257. </Style>
  258. </ResourceDictionary>